Home > Archives > k8s 2

k8s 2

Publish:

REPLICATION CONTROLLER

kubectl get nodes
kubectl create -f ./my-replication-controller.yaml
kubectl get rc
kubectl get pods
kubectl describe pod my-replication-controller-kl95h
kubectl delete pod my-replication-controller-kl95h
kubectl scale --replicas=4 -f ./my-replication-controller.yaml
kubectl get rc
kubectl describe rc my-replication-controller
kubectl delete rc my-replication-controller --cascade=false
kubectl delete pods my-replication-controller-4p8j9 --grace-period=0 --force

DEPLOYMENT

kubectl create -f ./my-deployment.yaml
kubectl get deployments
kubectl get pods --show-labels
kubectl get rs
kubectl get all
kubectl expose deploy hello-deployment --type=NodePort --name=my-deployment-servic
minikube service my-deployment-service --url
kubectl set image deploy/hello-deployment my-pod=zxcvbnius/docker-demo:v2.0.0
kubectl rollout status deploy hello-deployment
kubectl edit deploy hello-deployment
kubectl rollout history deploy hello-deployment
kubectl set image deploy/hello-deployment my-pod=zxcvbnius/docker-demo:v2.0.0 --record=true
kubectl rollout undo deployment hello-deployment
kubectl rollout history deploy hello-deployment
kubectl rollout undo deploy hello-deployment --to-revision=3

SERVICE

kubectl create -f ./my-deployment.yaml
kubectl get pods --show-labels
kubectl create -f ./my-service.yaml 
kubectl get svc
kubectl run -i --tty alpine --image=alpine --restart=Never -- sh
apk add --no-cache curl
minikube service hello-service --url

LABELS

kubectl create -f ./my-pod.yaml
kubectl get pods --show-labels
kubectl describe pod my-pod
kubectl label pods my-pod env=production
kubectl get pod my-pod --show-labels

kubectl get nodes --show-labels

update my-pod.yaml
  nodeSelector:
    hardware: high-memory

kubectl create -f ./my-pod-with-node-selector.yaml
kubectl label node localhost.localdomain hardware=high-memory
kubectl get pods
kubectl describe pod my-pod

HEALTH CHECK

kubectl create -f ./my-deployment-with-health-checks.yaml
kubectl get deploy
kubectl get pods
kubectl describe pod hello-deployment-6b56dd6494-986ng

SECRET

echo -n "root" > ./username.txt
echo -n "rootpass" > ./password.txt
kubectl create secret generic demo-secret-from-file --from-file=./username.txt --from-file=./password.txt
kubectl get secret
kubectl describe secret demo-secret-from-file

kubectl create secret generic demo-secret-from-literal \
--from-literal=username=root \
--from-literal=password=rootpass
kubectl get secret
kubectl get secret demo-secret-from-literal

echo -n "root" | base64
echo -n "rootpass" | base64
echo -n "rootpass" | base64 -d --解码
kubectl create -f ./my-secret.yaml
kubectl get secret
kubectl create -f ./my-pod.yaml
kubectl exec -it my-pod -- /bin/bash
echo $SECRET_USERNAME
echo $SECRET_PASSWORD

kubectl create -f ./my-pod-with-mounting-secret.yaml
kubectl exec -it my-pod-with-mounting-secret -- /bin/bash

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo