李明
|
kubernetes接触命令
kubectl run kubernetes-bootcamp --image=jocatalin/kubernetes-bootcamp:v1 --port=8080
kubectl describe deploy kubernetes-bootcamp
kubectl describe pods kubernetes-bootcamp-6b7849c495-xmmvh
kubectl proxy
curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/kubernetes-bootcamp-6b7849c495-xmmvh/
#如果需要从2 变成1 直接还用这个命令kubectl scale deploy kubernetes-bootcamp --replicas=2#可以看到在102运行了一个实例,在103在运行了一个实例kubectl get pods -o wide
kubectl describe deploy kubernetes-bootcamp
#原来是v1升级为v2kubectl set image deploy kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2 kubectl describe deploy kubernetes-bootcamp
kubectl rollout status deploy kubernetes-bootcamp
kubectl rollout undo deploy kubernetes-bootcamp#又变回v1了kubectl describe deploy kubernetes-bootcamp
kubectl delete deploy kubernetes-bootcamp
配置文件
mkdir services cd services vi nginx-pod.yaml
apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
kubectl create -f nginx-pod.yaml#文件写明的创建pod,就不可能创建deploykubectl get deploy kubectl get pods -o wide
#ip101启动代理kubectl proxy#ip101另一个窗口访问curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/nginx/
vi nginx-Deployment.yaml
apiVersion: apps/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
kubectl create -f nginx-Deployment.yaml kubectl get deploy kubectl get pods -o wide kubectl get pods -l app=nginx kubectl get pods -l app=nginx -o wide PS:常用的命令就说到这里吧,下次继续说说service和dns。 |
2019-02-22 11:25:02