Kubernetes
Kubernetes
Section titled “Kubernetes”go-zero services run well on Kubernetes with minimal configuration.
Deployment
Section titled “Deployment”apiVersion: apps/v1kind: Deploymentmetadata: name: order-apispec: replicas: 3 selector: matchLabels: {app: order-api} template: metadata: labels: {app: order-api} spec: containers: - name: order-api image: myregistry/order-api:latest ports: - containerPort: 8888 resources: requests: {cpu: 100m, memory: 128Mi} limits: {cpu: 500m, memory: 256Mi} livenessProbe: httpGet: {path: /healthz, port: 8888} initialDelaySeconds: 10 readinessProbe: httpGet: {path: /healthz, port: 8888} initialDelaySeconds: 5Service
Section titled “Service”apiVersion: v1kind: Servicemetadata: name: order-api-svcspec: selector: {app: order-api} ports: [{port: 8888, targetPort: 8888}]ConfigMap
Section titled “ConfigMap”apiVersion: v1kind: ConfigMapmetadata: name: order-api-configdata: app.yaml: | Name: order-api Host: 0.0.0.0 Port: 8888apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata: name: order-api-hpaspec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: order-api minReplicas: 2 maxReplicas: 20 metrics: - type: Resource resource: name: cpu target: {type: Utilization, averageUtilization: 60}kubectl apply -f k8s/kubectl rollout status deployment/order-api