Last active
April 13, 2020 13:36
-
-
Save thiagomatar/2ed197e589154dec60b643b9b67c5474 to your computer and use it in GitHub Desktop.
Kubernetes Cheat Sheet
kubectl get nodesfakubectl run nginx --image=nginxkubectl get podskubectl describe podskubectl describe pod pod-namekubectl get pods -o widekubectl create -f pod-definition.ymlkubectl get replicationcontrollerkubectl get replicasetkubectl describe replicasets
kubectl describe replicaset replicaset_namekubectl replace -f rs-definition.ymlkubectl scale --replicas=6 -f rs-definition.yml
kubectl scale --replicas=6 replicaset myappkubectl delete replicaset myappkubectl get allkubectl get deploymentskubectl describe deploymentskubectl rollout status deployment/myapp-deploymentkubectl rollout history deployment/myapp-deploymentkubectl apply -f deployment-definition.ymlkubectl set image deployment/myapp-deployment \ nginx:kubectl rollout undo deployment/myapp-deployment kubectl get ns kubectl describe ns kubectl get ns default -o yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: myapp-deployment | |
| labels: | |
| app: myapp | |
| type: front-end | |
| spec: | |
| template: | |
| metadata: # The data about the objects | |
| name: myapp-pod | |
| labels: | |
| app: myapp | |
| type: front-end | |
| spec: # This is additional information to kubernetes | |
| containers: | |
| - name: nginx-container | |
| image: nginx | |
| replicas: 3 | |
| selector: | |
| matchLabels: | |
| app: myapp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 # The version of Kubernetes API to using to create objects | |
| kind: Pod # The type of object that will be create | |
| metadata: # The data about the objects | |
| name: myapp-pod | |
| labels: | |
| app: myapp | |
| type: front-end | |
| spec: # This is additional information to kubernetes | |
| containers: | |
| - name: nginx-container | |
| image: nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # deprecated prefer use replicaset instead | |
| apiVersion: v1 | |
| kind: ReplicationController | |
| metadata: | |
| name: myapp-rc | |
| labels: | |
| app: myapp | |
| type: frontend | |
| spec: | |
| template: | |
| metadata: # The data about the objects | |
| name: myapp-pod | |
| labels: | |
| app: myapp | |
| type: front-end | |
| spec: # This is additional information to kubernetes | |
| containers: | |
| - name: nginx-container | |
| image: nginx | |
| replicas: 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: ReplicaSet | |
| metadata: | |
| name: myapp | |
| spec: | |
| template: | |
| metadata: # The data about the objects | |
| name: myapp-pod | |
| labels: | |
| app: myapp | |
| type: front-end | |
| spec: # This is additional information to kubernetes | |
| containers: | |
| - name: nginx-container | |
| image: nginx | |
| replicas: 3 | |
| selector: | |
| matchLabels: | |
| type: front-end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: myapp-services | |
| spec: | |
| type: NodePort | |
| ports: | |
| - targetPort: 80 | |
| port: 80 | |
| nodePort: 30008 | |
| selector: | |
| app: myapp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment