Difference between revisions of "Kubectl"

From John Freier
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 7: Line 7:
  
  
 +
'''Apply a configuration yaml file.'''
 +
  kubectl apply -f [name_of_file]
  
'''Pull Local Images'''
+
'''Get the configuration yaml file.'''
 +
  kubectl get pod [podname]  --namespace [namespace] -o yaml
  
Pull images from localhost podman
+
 
   eval $(minikube podman-env)
+
== Deploy ==
 +
'''Get Deployments'''
 +
  kubectl get deployments --namespace=cs
 +
 
 +
 
 +
'''Delete Deployments'''
 +
  kubectl delete deployment [name_of_deployment] --namespace=cs
 +
 
 +
 
 +
 
 +
== Pods ==
 +
'''Get Pods'''
 +
 
 +
This gets all the pods.
 +
  kubectl get pods --namespace cs
 +
 
 +
 
 +
Delete a pod
 +
  kubectl delete pod [pod_name]
 +
 
 +
 
 +
== Remote in to a pod ==
 +
This will allow you to execute a command which in the example below it will start up a shell.
 +
  kubectl exec --stdin --tty [pod_name] --namespace [namespace] -- /bin/sh
 +
 
 +
 
 +
== Volume ==
 +
 
 +
List Persistent Volumes Claims
 +
  kubectl describe pvc --namespace=cs
 +
 
 +
 
 +
== Logs ==
 +
Get the logs from a pod.
 +
   kubectl logs -p [pod_name] --namespace=cs
 +
 
 +
For any sidecars you may need to specifiy a container.
 +
    kubectl logs -p [pod_name] --namespace=cs --container gce-proxy
 +
 
 +
You can also follow the logs live with the following flaf.
 +
  --follow
 +
 
 +
== Events ==
 +
Get a list of events.
 +
 
 +
  kubectl get events
 +
 
 +
 
 +
== Extra commands to help.==
 +
If you have to include a name space.
 +
  --namespace scdf-jf
 +
 
 +
To be past any SSL issues.
 +
  --insecure-skip-tls-verify

Latest revision as of 10:03, 17 May 2024

Kubectl is an application that interacts with Kubernetes clusters.

Check the context

This checks who kubectl is connected to.

 kubectl config current-context


Apply a configuration yaml file.

 kubectl apply -f [name_of_file]

Get the configuration yaml file.

 kubectl get pod [podname]  --namespace [namespace] -o yaml


Deploy

Get Deployments

 kubectl get deployments --namespace=cs


Delete Deployments

 kubectl delete deployment [name_of_deployment] --namespace=cs


Pods

Get Pods

This gets all the pods.

 kubectl get pods --namespace cs


Delete a pod

 kubectl delete pod [pod_name]


Remote in to a pod

This will allow you to execute a command which in the example below it will start up a shell.

 kubectl exec --stdin --tty [pod_name] --namespace [namespace] -- /bin/sh


Volume

List Persistent Volumes Claims

 kubectl describe pvc --namespace=cs


Logs

Get the logs from a pod.

 kubectl logs -p [pod_name] --namespace=cs

For any sidecars you may need to specifiy a container.

   kubectl logs -p [pod_name] --namespace=cs --container gce-proxy

You can also follow the logs live with the following flaf.

 --follow

Events

Get a list of events.

 kubectl get events


Extra commands to help.

If you have to include a name space.

 --namespace scdf-jf

To be past any SSL issues.

 --insecure-skip-tls-verify