httpGet 指针
apiVersion: v1 kind: Pod metadata: name: liveness-httpget-pod namespace: default spec: containers: - name: liveness-httpget-container image: busybox:latest imagePullPolicy: IfNotPresent command: ["/bin/sh","-c","mkdir -p /data/web/html; echo 'abc' > /data/web/html/index.html; /bin/httpd -f -h /data/web/html"] livenessProbe: httpGet: port: 80 path: /index.html initialDelaySeconds: 1 periodSeconds: 3
POD
apiVersion: apps/v1 # POD名字 kind: ReplicaSet metadata: name: myapp # 放入那个名称空间 namespace: default spec: replicas: 2 selector: matchLabels: app: myapp release: canary template: metadata: name: myapp-pod labels: app: myapp release: canary environment: qa spec: containers: - name: myapp-container image: ikubernetes/myapp:v1 ports: - name: http containerPort: 80
1 apiVersion: v1 2 kind: Service 3 metadata: 4 name: myapp 5 namespace: default 6 7 spec: 8 selector: 9 app: myapp 10 release: canary 11 clusterIP: 10.99.99.99 12 type: NodePort 13 ports: 14 - port: 80 15 targetPort: 80 16 nodePort: 30080
#查看所解析的地址
dig -t A myapp-svc.default.svc.cluster.local. @10.96.0.10
#查看本机的kube=DNS地址
kubectl get svc -n kube-system
# 修改server访问只用一台去轮训,None是取消一台,让所有的pod继续轮训。
kubectl patch svc myapp -p '{"spec":{"sessionAffinity":"ClientIP"}}'
kubectl patch svc myapp -p '{"spec":{"sessionAffinity":"None"}}'