Implementación de la redistribución de apps de Hello

Implementación de Kubernetes para la redistribución de la app de Hello de GKE.

Muestra de código

YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hello-web
  name: hello-web
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-web
  template:
    metadata:
      labels:
        app: hello-web
    spec:
      # Pod anti affinity config START
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - hello-web
            topologyKey: kubernetes.io/hostname
      # Pod anti affinity config END
      containers:
      - image: us-docker.pkg.dev/google-samples/containers/gke/hello-app-redis:1.0  # change to the image name you built
        name: hello-app
        # Readiness probe config START
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 1
          periodSeconds: 1
          successThreshold: 1
          timeoutSeconds: 1

¿Qué sigue?

Para buscar y filtrar muestras de código para otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.