alias k=kubectl
PODS
https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/
kubectl run nginx --image=nginx
kubectl create -f nginx.yml
apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx-container image: nginx
kubectl describe pods nginx-pod
kubectl get pods -o wide
kubectl edit pod nginx-pod
kubectl delete pod nginx-pod
kubectl get pod pod-name -o yaml > pod-definition.yaml
Replication Controller
kubectl create -f rc-definition.yml
apiVersion: v1 kind: ReplicationController metadata: name: nginx spec: replicas: 3 selector: app: nginx template: metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80
kubectl get rc
Replica Set
kubectl create -f rs-definition.yml
apiVersion: apps/v1 kind: ReplicaSet metadata: name: frontend labels: app: guestbook tier: frontend spec: # modify replicas according to your case replicas: 3 selector: matchLabels: tier: frontend template: metadata: labels: tier: frontend spec: containers: - name: php-redis image: gcr.io/google_samples/gb-frontend:v3
kubectl get replicaset
kubectl describe replicaset
kubectl replace
kubectl scale --replicas=3 rs/myrs
kubectl get rs myrs -o yaml
Deployments
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
kubectl create -f mydeployment.yml
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80
kubectl get all
An overall good explanation of Kubernetes is here https://dzone.com/storage/assets/11459286-dzone-refcard292-advancedkubernetes314.pdf
No comments:
Post a Comment