【二】初步使用Kubernetes

tech2022-08-18  112

1、新建命名空间,在该命名空间中创建一个pod

命名空间名称:cka

pod名称:pod-01

镜像:nginx

kubectl create ns cka vim pod-01.yaml apiVersion: v1 kind: Pod metadata: namespace: cka name: pod-01 labels: app: pod-01 spec: restartPolicy: Always containers: - name: pod-01 image: nginx imagePullPolicy: IfNotPresent kubectl apply -f pod-01.yaml

2、创建一个deployment并暴露Service

名称:alibaba-666

镜像:nginx

kubectl create deployment alibaba-666 --image=nginx kubectl expose deployment alibaba-666 --type=NodePort --port=80 --target-port=80 --name=alibaba-666

3、列出命名空间下指定标签pod

命名空间名称:kube-system

标签:k8s-app=kube-dns

kubectl get pod -n kube-system -l k8s-app=kube-dns

 

最新回复(0)