0% found this document useful (0 votes)
7 views

Basic commands that can be used

Uploaded by

LK
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Basic commands that can be used

Uploaded by

LK
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic commands that can be used:

kubectl run
kubectl cluster-info
kubectl get nodes (-o wide) :gets OS version
kubectl get pods/services/namespaces/roles/rolebindings (-o wide) (-A all pods in
all namespaces)
kubectl describe pod/role/rolebinding (nginx) --record (to have history)
kubectl create -f pod-definition.yaml
kubectl delete pod (i.e. nginx)
kubectl run redis --image=redis123 --dry-run=client -o yaml
kubectl get replicaset/replicacontroller
kubectl replace -f replicaset-definition.yaml (when changing a parameter in .yml
file)
kubectl scale --replicas=6 -f <file>.yaml
kubectl delete replicaset <file>.yaml
kubectl edit replicaset <file> (opens in vim. Changes are directly in memory.
Change it and save it)
kubectl scale replicaset <file> --replicas=2
kubectl get all (pods, replicas, deployments)
kubectl apply -f <file>.yaml (updates the pods)
kubectl rollout undo deployment/myapp-deployment (rolls back to older version)
kubectl --deployment/ (check the status)
kubectl rollout history deployment (all deployments)
kubectl set image deployment myapp --nginx=<> --record (with the record option, you
get more details on the deployments
kubectl get nodes (if various nodes)
kubectl config set-context $(kubectl config current-context) --namespace=<> (this
is to change the default namespace)
kubectl run redis --image=redis --namespace=<> (creates and runs redis in a certain
namespace)
kubectl run nginx --dry-run=client (with the dry-run extension we check the command
without making the object)
kubectl exec -it (pod/container) ls /var/run/secrets/kubernetes (executes a cmd in
a container)
kubectl logs -f event-simulator-pod event-simulator
kubectl top node/pod (resources of the pods/nodes)
kubectl config view (view the config file. The file is located in ~/.kube/config)
kubectl auth can-I create deployments (check access based on the roles, e.g as
developer)
kubectl -apiserver -h grep | enable-admission-plugins (to check what is enabled in
the system) or ps -ef |grep kube-apiserver |grep admission-plugins
kubectl api-resources
kubectl explain job
kubectl /var/log/pods/
some useful docker commands:

docker run -d --name=redis redis (should be in docker repository) (-d: runs in the
background)
docker run -d --name=vote -p 5000:80 --link redis:redis voting app (link, likns 2
containers)
docker run -e APP_COLOR=pink myapp (env variable)
sudo docker version (docker version)
docker ps -a (list of containers, with -a you get also the previous running
containers)
docker stop <container id or name>
docker rm <container id or name>
docker images :list of the images available in docker
docker rmi :removes images
docker pull nginx :gets image, not install it, just download
docker exec <container id or name> cat /etc/host :executes a linux command in the
container
docker attach <container id or name> :if previously run command is given with the
-d option and you want to bring it it in the foreground again
docker run -it <image> (option -i: intercative-in case an input is requested by the
user and -t to be given by terminal)
docker run -p 80:5000 <image> :in order to access from outside our application. In
this case 500 is the container port and 80 is the docker port
docker run -v /opt/datadir:/var/lib/mysql mysql : /opt/datadir is a volume in the
host and /var/lib/mysql is a volume inside the container. Upon deletion of the
container, we can get the logs of the pod within the host, in a specific directory
docker inspect container <container> :details on the container
docker inspect container <container> :details on the container
docker logs <container> :view the logs
Help commands:

Helm list
Helm list uninstall my-release
Helm pull --untar bitnami/wordpress (pull: just to download it not to install it)
Helm install release-4 ./worldpress
Systemctl status/restart kubelet
(systemctl: manages both system and service configurations. Enables admin to manage
the OS and control the status of the services. Kubelet is the component that runs
on all the machines in the cluster. Kubectl: the cmd line until you talk to your
cluster

Kubelet (runs on all machines in the cluster)


Echo -n 'sql' | base64 (creates 64bits for encryption)
Echo -n '64output of the above' | base64 --decode

You might also like