kubectl

Overview

Kubectl is a command line tool for managing resources in a Kubernetes cluster. You can find installation instructions here.

Usage

Configuration

Dump the config

$ kubectl config view

List pods

$ kubectl get pods

List labels

$ kubectl get pods -L <label>

Deployment

kubectl run

Set environment variables

$ kubectl run <name> --image=<image> --env="<ENVVAR>=<value>"

Expose a port

$ kubectl run <name> --image=<image> --port=<port>

Run multiple replicas

$ kubectl run <name> --image=<image> --replicas=<n>

Override the default command

$ kubectl run <name> --image=<image> -- <cmd> <arg1> ... <argN>

Schedule command to run

$ kubectl run <name> --schedule="<cron string>"

kubectl expose

Expose a port publicly

$ kubectl expose deployment <name> --port=<container port> --target-port=<host port>

kubectl delete

Delete an application

$ kubectl delete deployment,service <name>

Resources

  • https://kubernetes.io/docs/user-guide/prereqs/