Skip to content

Kubectl

kimschles edited this page Aug 8, 2018 · 18 revisions

https://www.katacoda.com/courses/kubernetes/launch-single-node-cluster https://www.katacoda.com/courses/kubernetes/kubectl-run-containers

get, describe and delete

Check your version of minikube

  • minikube version

Start your cluster

  • minikube start

See details about your cluster and its health

  • kubectl cluster-info

View the nodes in your cluster

  • kubectl get nodes

More info about nodes in your cluster

  • kubectl get nodes -o wide

See detailed information about a specific node

  • kubectl describe node <name_of_node>

Deploy a container onto the cluster

  • kubectl run <name_of_deployment> <properties>
  • kubectl run --image=<name_of_image_here> server --port=80

Check the status of your pods

  • kubectl get pods

Delete a pod

  • kubectl delete pod <name_of_pod>

View the status of your deployment

  • kubectl get deployments

More information on your deployment

  • kubectl describe deployment <name_of_deployment>

Show the services you are running

  • kubectl get svc

Scale up the number of pods you have running

  • kubectl scale --replicas-3 deployment http

Provide a dynamic port to a container with NodePort

  • kubectl expose deployment first-deployment --port=80 --type=NodePort

See your namespaces

  • kubectl get ns

Create a new namespace

  • kubectl create ns <name_space_here>

See your contexts

  • kubectl config get-contexts

Configure a Context

  • kubectl config set-context workshop

Set a context

  • kubectl config set-context <name_space_here> --cluster <cluster_name_here> --user <user_here>

Switch to a specific context

  • kubectl config user-context <name_of_context>

Deploy a specific file

  • kubectl apply -f <file>

Apply any command to a specific namespace

  • kubectl <command_here> --namespace=<name>

Kubens

Note: this is a package that needs to be downloaded https://github.com/ahmetb/kubectx

See all namespaces

  • kubens

Switch to a specific namespace

  • kubens <namespace>

See your deployments

  • kubectl get deployments
Clone this wiki locally