Difference between revisions of "Kubectl"

From wikieduonline
Jump to navigation Jump to search
 
(17 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
* To install in [[macOS]] execute: <code>[[brew install kubernetes-cli]]</code>
 
* To install in [[macOS]] execute: <code>[[brew install kubernetes-cli]]</code>
 
* [[Kubectl in Amazon Linux]]
 
* [[Kubectl in Amazon Linux]]
* Ubuntu [[Kubernetes installation]]: <code>[[snap install kubectl --classic]]</code>
+
* [[Ubuntu kubectl installation]]
 
* <code>[[~/.kube/config]]</code>
 
* <code>[[~/.kube/config]]</code>
 +
* [[scoop install kubectl]]
  
 
== Commands ==
 
== Commands ==
Line 106: Line 107:
 
* https://stackoverflow.com/questions/tagged/kubectl?tab=Votes
 
* https://stackoverflow.com/questions/tagged/kubectl?tab=Votes
 
* [[Kubernetes quiz]]
 
* [[Kubernetes quiz]]
 +
* [[Merge multiple kubeconfigs]]: <code>[[~/.kube/config]]s</code> into one using <code>[[kubectl konfig merge]]</code>
  
 
== Related ==
 
== Related ==
 
* [[Krew]]
 
* [[Krew]]
* [[kops]]
+
* <code>[[kops]]</code>
 
* [[Kots]] kubectl plugin
 
* [[Kots]] kubectl plugin
 
* [[K9s]]
 
* [[K9s]]
* <code>[[aws eks]] --region $(terraform output -raw region) [[update-kubeconfig]] --name $(terraform output -raw cluster_name)</code>
+
* <code>[[aws eks]] --region $([[terraform output -raw]] region) [[update-kubeconfig]] --name $([[terraform output -raw]] cluster_name)</code>
 
* <code>[[kubectl-convert]]</code>
 
* <code>[[kubectl-convert]]</code>
 
* <code>[[kubeadm]]</code>
 
* <code>[[kubeadm]]</code>
 
* <code>[[Error: flags cannot be place before plugin name]]</code>
 
* <code>[[Error: flags cannot be place before plugin name]]</code>
 +
* <code>[[kubectl.kubernetes.io]]</code>
 +
* [[kubectl (alias)]]
 +
* [[Terraform: kubectl provider]]
 +
* <code>[[kubectl --request-timeout]]</code>
  
 
== See also ==
 
== See also ==

Latest revision as of 16:02, 10 July 2024

Installation[edit]

Commands[edit]

Kubectl information commands[edit]

kubectl operation commands[edit]

kubectl command reference[edit]

The following table includes short descriptions and the general syntax for all of the kubectl operations:[2]

  • Apply kubectl apply -f FILENAME [flags]. Apply a configuration change to a resource from a file or stdin. Allows to create a Pod.
  • Attach kubectl attach POD -c CONTAINER [-i] [-t] [flags]:Attach to a running container either to view the output stream or interact with the container (stdin)
  • Auto Scale kubectl autoscale (-f FILENAME \| TYPE NAME \| TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]: Automatically scale the set of pods that are managed by a replication controller


  • Cluster Info kubectl cluster-info [flags] :Display endpoint information about the master and services in the cluster
  • Create kubectl create -f FILENAME [flags]: Create one or more resources from a file or stdin
    • kubectl create namespace myexamplenamespace
    • kubectl create sa my_new_user (Create service account for your my_new_user)
    • kubectl create -f mypod.yaml


  • Delete kubectl delete (-f FILENAME \| TYPE [NAME \| /NAME \| -l label \| --all]) [flags] :Delete resources
    • kubectl delete --all namespaces
  • Describe kubectl describe (-f FILENAME \| TYPE [NAME_PREFIX \| /NAME \| -l label]) [flags] : Detailed state of one or more resources.
    • kubectl describe pod MyPodName
    • kubectl describe pods
    • kubectl describe replicaset MyReplicaName
  • Edit kubectl edit (-f FILENAME \| TYPE NAME \| TYPE/NAME) [flags] : Edit and update the definition of one or more resources on the server by using the default editor.
  • Execute kubectl exec POD [-c CONTAINER] [-i] [-t] [flags] [-- COMMAND [args...]]: Execute a command against a container in a pod
  • Logs kubectl logs POD [-c CONTAINER] [--follow] [flags]: Print the logs for a container in a pod.
    • kubectl logs -l app=elasticsearch (using labels: -l)
  • Run kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [flags]: Run a specified image on the cluster.
  • Stop kubectl stop
  • Version kubectl version [--client] [flags]: Display the Kubernetes version running on the client and server.

Activities[edit]

Related[edit]

See also[edit]

Advertising: