K8s basic configuration

Time:2020-11-23

Installing kubectl

Using Tsinghua source

Red hat system

$ cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=```
https://mirrors.tuna.tsinghua.edu.cn/kubernetes/yum/repos/kubernetes-el7-$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
$ yum install -y kubectl

Debian system

$ sudo apt-get update && sudo apt-get install -y apt-transport-https
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ echo "deb https://mirrors.tuna.tsinghua.edu.cn/kubernetes/apt kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update
$ sudo apt-get install -y kubectl

to configure

View version

kubectl version

inspect

Check that kubectl is configured correctly by getting the cluster state

kubectl cluster-info

If kubels is correctly configured, then you can see that kubels is returned to the cluster.

If you see information like the following being returned, kubectl is not configured correctly to properly access your kubernetes cluster.

The connection to the server <server-name:port> was refused - did you specify the right host or port?

For example, if you plan to run a kubernetes cluster on a laptop (local), you need to first install tools such as minikube, and then rerun the above command.

If kubectl cluster info can return a URL response, but you cannot access your cluster, you can use the following command to check whether the configuration is correct:

kubectl cluster-info dump

Minikube

https://kubernetes.io/zh/docs…

Microk8s

Install using snap

sudo snap install microk8s --classic

Start and view the status of the microk8s:

Sudo microk8s. Start // start microk8s
Microk8s status -- wait ready // query the current status

Since it is a single node k8s, kubectl can be directly integrated into alias
modify~/.bash_aliasesAdd the following
alias kubectl='microk8s kubectl'

Recommended Today

Rust programming video tutorial (Advanced) – 024_ 3 syntax of all modes 3

Video address Headline address:https://www.ixigua.com/i677586170644791348…Station B address:https://www.bilibili.com/video/av81202308/ Source address GitHub address:https://github.com/anonymousGiga/learn_rus… Explanation content 1. Ignore values in mode(1) Use_ Ignore entire valueexample: fn foo(_: i32, y: i32) { println!(“This code only uses the y parameter: {}”, y); } fn main() { foo(3, 4); } Note: placeholders are used for parameters in the function, mainly when implementing […]