It's easy nowaday to build up a k8s cluster, so dont worry, lets move step by step
step 1 host with ubuntu
At the very beginning, you at least need a host which running ubuntu 16.04+ on it or what ever local host you have, but this tutorial is all about k8s with ubuntu stuff, so assume you've got those.
step 2 install docker ce
There are kinds of elder version of docker on ubuntu which called docker.io etc etc
We are not talking about the above metioned but going to install the docker ce version
Just follow the shell script below
# (Install Docker CE)
## Set up the repository:
### Install packages to allow apt to use a repository over HTTPS
apt-get update && apt-get install -y \
apt-transport-https ca-certificates curl software-properties-common gnupg2
Finally, you still need a daemon config file for docker like that:
# Set up the Docker daemon
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
EOF
This line "exec-opts": ["native.cgroupdriver=systemd"], is typically not required but here it is!
In order to make it works well with k8s, you'd better do it the same
This line "registry-mirrors": ["http://hub-mirror.c.163.com"] is also not required, for some reason in China mainland, you may need something magical like that : )
After the above all have done then restart docker service like that:
Arg --image-repository registry.aliyuncs.com/google_containers is for China mainland issue, something magical you know~
Arg --kubernetes-version v1.18.0 is about which k8s version you want, here I choose v1.18.0, actually you can pick up whatever version you want if there it is.
Arg --pod-network-cidr=10.244.0.0/16 is important because that define which network cidr that k8s will use, typically there are kinds of cidr of k8s, if you do not name one, then it will use the default, and the 10.244.0.0/16 format means I choose flannel as my cidr
Then wait for minutes, if there is no any error occur that means you are almost there
# if you want to run as regular user, then do it below
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
first of all
It's easy nowaday to build up a k8s cluster, so dont worry, lets move step by step
step 1 host with ubuntu
At the very beginning, you at least need a host which running ubuntu 16.04+ on it or what ever local host you have, but this tutorial is all about k8s with ubuntu stuff, so assume you've got those.
step 2 install docker ce
There are kinds of elder version of docker on ubuntu which called docker.io etc etc
We are not talking about the above metioned but going to install the docker ce version
Just follow the shell script below
Finally, you still need a daemon config file for docker like that:
This line
"exec-opts": ["native.cgroupdriver=systemd"],
is typically not required but here it is!In order to make it works well with k8s, you'd better do it the same
This line
"registry-mirrors": ["http://hub-mirror.c.163.com"]
is also not required, for some reason in China mainland, you may need something magical like that : )After the above all have done then restart docker service like that:
step 3 install k8s
Befor install k8s, you may need to do these:
Now you are ok to install k8s
Let's initialization the k8s
Arg
--image-repository registry.aliyuncs.com/google_containers
is for China mainland issue, something magical you know~Arg
--kubernetes-version v1.18.0
is about which k8s version you want, here I choose v1.18.0, actually you can pick up whatever version you want if there it is.Arg
--pod-network-cidr=10.244.0.0/16
is important because that define which network cidr that k8s will use, typically there are kinds of cidr of k8s, if you do not name one, then it will use the default, and the10.244.0.0/16
format means I choose flannel as my cidrThen wait for minutes, if there is no any error occur that means you are almost there
Finally, the last move: install flannel
All right check out the below command and make sure everything is fine~