Check the versions on the client and server.
$ kubectl version
View information about the master, including its dashboard location.
$ kubectl cluster-info
View the nodes in the cluster.
$ kubectl get nodes
A deployment is the definition of the structure of an application. It is used to both deploy the application and maintain it.
Create a deployment called my-app with a single image called my-image listening on port 8080.
$ kubectl run my-app --image=my-registry/my-image:1.0 --port=8080
View all deployments.
$ kubectl get deployments
Create a proxy to expose the private Kubernetes network.
$ kubectl proxy
Perform a rolling update on the my-app deployment to a new version of the image.
$ kubectl set image deployments/my-app my-registry/my-image:2.0
View the status of the rollout.
$ kubectl rollout status deployments/my-app
Roll back the update.
$ kubectl rollout undo deployments/my-app
Pods group logically related, tightly coupled containers, such as a service and its database. Pods are the atomic unit in Kubernetes.
View all pods.
$ kubectl get pods
Describe containers and images within a pod.
$ kubectl describe pod my-pod
View the logs for a pod.
$ kubectl logs my-pod
Execute a command on a pod. Add the "it" argument for an interactive command.
$ kubectl exec my-pod ls
$ kubectl exec -it my-pod bash
Add a label to a pod.
$ kubectl label pod my-pod my-label
View all pods with a given label.
$ kubectl get pods -l my-label
A service defines a logical set of pods and a policy for accessing them.
Create a service on the my-app deployment and expose it publicly on port 8080.
$ kubectl expose deployments/my-app --type="NodePort" --port=8080
Delete a service using a label.
$ kubectl delete service -l my-label
Scale the my-app deployment to 4 replicas.
$ kubectl scale deployments/my-app --replicas=4