Kubectl: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
==kubeconfig== | ==kubeconfig== | ||
Kubernetes components like <code>kubelet</code>, <code>kube-controller-manager</code>, or <code>kubectl</code> use the <code>kubeconfig</code> file to interact with the Kubernetes API. Usually, the <code>kubectl</code> or oc commands use the <code>kubeconfig</code> file. | Kubernetes components like <code>kubelet</code>, <code>kube-controller-manager</code>, or <code>kubectl</code> use the <code>kubeconfig</code> file to interact with the Kubernetes API. Usually, the <code>kubectl</code> or <code>oc</code> commands use the <code>kubeconfig</code> file. | ||
The <code>kubeconfig</code> file's default location for <code>kubectl</code> or <code>oc</code> is the <code>~/.kube</code> directory. Instead of using the full <code>kubeconfig</code> name, the file is just named config. The default location of the <code>kubeconfig</code> file is <code>~/.kube/config</code>. There are other ways to specify the <code>kubeconfig</code> location, such as the <code>KUBECONFIG</code> environment variable or the <code>kubectl --kubeconfig</code> parameter. | |||
The <code>kubeconfig</code> file is a YAML file containing groups of clusters, users, and contexts. | |||
* '''A cluster''' is a Kubernetes or OpenShift cluster. | |||
* '''A user''' is a credential used to interact with the Kubernetes API. | |||
* '''A context''' is a combination of a cluster and a user. Every time you execute an <code>oc</code> or <code>kubectl</code> command, you reference a context inside <code>kubeconfig</code>. | |||
==References== | ==References== |
Revision as of 01:00, 13 April 2023
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg\
https://packages.cloud.google.com/apt/doc/apt-key.gpg
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg]\
https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update && sudo apt install -y apt-transport-https curl
sudo apt install -y docker-ce=5:20.10.14~3-0~ubuntu-focal\
kubelet=1.23.5-00 kubeadm=1.23.5-00 kubectl=1.23.5-00
sudo apt-mark hold docker-ce kubelet kubeadm kubectl
sudo apt install docker-compose
kubeconfig
Kubernetes components like kubelet
, kube-controller-manager
, or kubectl
use the kubeconfig
file to interact with the Kubernetes API. Usually, the kubectl
or oc
commands use the kubeconfig
file.
The kubeconfig
file's default location for kubectl
or oc
is the ~/.kube
directory. Instead of using the full kubeconfig
name, the file is just named config. The default location of the kubeconfig
file is ~/.kube/config
. There are other ways to specify the kubeconfig
location, such as the KUBECONFIG
environment variable or the kubectl --kubeconfig
parameter.
The kubeconfig
file is a YAML file containing groups of clusters, users, and contexts.
- A cluster is a Kubernetes or OpenShift cluster.
- A user is a credential used to interact with the Kubernetes API.
- A context is a combination of a cluster and a user. Every time you execute an
oc
orkubectl
command, you reference a context insidekubeconfig
.
References
| ||