标签:inf pod ima bec 访问 容器 uber clust api
查看pod配置清单参考: (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/)
[root@k8s-master01 ~]# kubectl explain pods.metadata.[.........]
[root@k8s-master01 ~]# kubectl explain pods.spec.[........]
[root@k8s-master01 ~]# kubectl explain pods.spec.containers.ports
containerPort : 容器开放端口
hostIP: 绑定宿主机ip
hostPort:绑定宿主机端口
name: 必须是IANA_SVC_NAME,并且是pod唯一
protocol :协议端口 必须是UDP TCP SCTP类型,默认TCP
语法:
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx-1
ports:
- protocol: TCP
conainerPort: 80
name: http
hostPort: 8888
[root@k8s-master01 ~]# cat nginx_pods.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-demo1
namespace: prod
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx-1
ports:
- protocol: TCP
containerPort: 80
hostPort: 8888
name: http-nginx
[root@k8s-master01 ~]# kubectl apply -f nginx_pods.yaml
[root@k8s-master01 ~]# kubectl get pods/pod-demo1 -n prod -o wide
ports:
- protocol: TCP
containerPort: 80
hostPort: 8888
name: http-nginx
hostIP: 192.168.1.101
[root@k8s-master01 ~]# kubectl create service clusterip nginx-dep --tcp=80:80
根据开放节点数量,直接访问(所有node节点都可以访问)
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx-1
hostNetwork: true
二进制安装kubernetes1.14.1-pod配置清单之客户端访问方式03
标签:inf pod ima bec 访问 容器 uber clust api
原文地址:https://blog.51cto.com/9025736/2397839