In this post, I will install the kubernetes with external etcd. Most of instrcution come from here. I will follow step by step as the beginner.

 

kubeadm-init.yaml
0.00MB

 

1. Pre-requsite

 

At first I need to prepare the hosts for Kubernetes components. In my case, I have 5 nodes, one for master, one for external etcd and three for workers. After I prepare these nodes. I need to update "/etc/hostname" and "/etc/hosts" files propertly. For example, I have to change hostname to "m1" as master node.

# hostname m1

# vi /etc/hostname
m1

# vi /etc/hosts
127.0.0.1       localhost       m1
147.75.94.251 m1
147.75.92.69 e1
147.75.92.139 w1
147.75.92.71 w2

After this, I need to log-out and log-in again.

Kubernetes use Docker engine. Therefore, I need to install Docker. I will follow this instruction. In my case, I will run this kubernetes over Ubuntu 16.04. This is overview.

sudo apt-get update
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

I need to check docker info. It will be like below. I need to check "Cgroup Driver: cgroupfs" as default.

# docker info
Server Version: 18.09.6
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive

From this instruction, I will change this driver from "cgroupsfs" to "systemd". This change affect lots of issue during Kubernetes installation. Therefore I need to remember this.

cat > /etc/docker/daemon.json <{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
systemctl daemon-reload
systemctl restart docker

After this, Cgroup Driver will be changed 

# docker info
Cgroup Driver: systemd

 

2. Install kubelet, kubeadm and kubectl

 

Kubelet (daemon on each node has the role to handle conatiner), kubeadm (daemon on each node has the role to setup master and workers) and kubectl (daemon on each node has the role to manage the cluster) are necessary components.

apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat </etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

After installation, I need to check the directories which are created during the installation. "/etc/kubernetes/" and "/var/lib/kubelet/pki/" and "/etc/systemd/system/kubelet.service.d/" are created. 

# ls /etc/kubernetes/ 
manifests 
# ls /etc/kubernetes/manifests/ 
# ls /var/lib/kubelet/ 
pki 
# ls /var/lib/kubelet/pki/ 
kubelet.crt  kubelet.key 
# ls /etc/systemd/system/kubelet.service.d/
10-kubeadm.conf 

To work Kubernetes normally, Kubelet work normally at first. I can check the status with "systemctl status kubelet". At this moment, it is not activate.

# systemctl status kubelet

  kubelet.service - kubelet: The Kubernetes Node Agent

   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)

  Drop-In: /etc/systemd/system/kubelet.service.d

           └─10-kubeadm.conf

   Active: activating (auto-restart) (Result: exit-code) since Wed 2019-05-22 10:59:59 UTC; 2s ago

     Docs: https://kubernetes.io/docs/home/

  Process: 12883 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=

 Main PID: 12883 (code=exited, status=255)

May 22 10:59:59 e1 systemd[1]: kubelet.service: Main process exited, code=exited, status=255/n/a

May 22 10:59:59 e1 systemd[1]: kubelet.service: Unit entered failed state.

May 22 10:59:59 e1 systemd[1]: kubelet.service: Failed with result 'exit-code'.

To see more details, I will look at the logs in "/var/log/syslog". From logs, I can check I need "config.yaml" file. Keep this issue and go to next step. This file will be created with "kubectl init" command later.

# tail -f /var/log/syslog

systemd[1]: kubelet.service: Service hold-off time over, scheduling restart.

systemd[1]: Stopped kubelet: The Kubernetes Node Agent.

systemd[1]: Started kubelet: The Kubernetes Node Agent.

kubelet[12865]: F0522 10:59:49.732907   12865 server.go:193] failed to load Kubelet config file /var/lib/kubelet/config.yaml, error failed to read kubelet config file "/var/lib/kubelet/config.yaml", error: open /var/lib/kubelet/config.yaml: no such file or directory

systemd[1]: kubelet.service: Main process exited, code=exited, status=255/n/a

systemd[1]: kubelet.service: Unit entered failed state.

systemd[1]: kubelet.service: Failed with result 'exit-code'.

I need to match the cgroup driver with the value "systemd". In the instruction, there is the comment like below.

However there are no "/etc/default/kubelet" and "/var/lib/kubelet/kubeadm-flags.env". So I can not update this with this instruction. Please look at the result from "systemctl status kubelet". I can see "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf". This is the loaded file when kubelet is started.

# Note: This dropin only works with kubeadm and kubelet v1.11+

[Service]

Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"

Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"

Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=systemd"

# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically

EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env

# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use

# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.

EnvironmentFile=-/etc/default/kubelet

ExecStart=

ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

I will add the red text, Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=systemd". And restart the kubelet with "systemctl daemon-reload" and "systemctl restart kubelet". However, it is still not activated due to no config.yaml.

 

 

3. Install external etcd cluster

 

I have alread posted in here. To create the etcd cluster, It is not easy. However, I can make these with this instruction easliy. This etcd will be created as one of container application which are managed by Kubernetes. On the external etcd node, I have to run command below.

cat << EOF > /etc/systemd/system/kubelet.service.d/20-etcd-service-manager.conf 

[Service] 

ExecStart= 

ExecStart=/usr/bin/kubelet --address=127.0.0.1 --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true 

Restart=always 

EOF

systemctl daemon-reload

systemctl restart kubelet

 Please note that there is no option for cgroup drivers. Therefore, I need to change something.

Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=systemd"
ExecStart=
ExecStart=/usr/bin/kubelet --address=0.0.0.0 --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true $KUBELET_EXTRA_ARGS
Restart=always

The file name start with 20-etcd-service-manager.conf due to "20", so it has higher priority rather than 10-kubeadm.conf. After running this, I can check the "systemctl status kubelet" and "/var/log/syslog". The kubelet does not works with some error. This error is different from above. The first error above is happend after 10-kubeadm.conf loading. However this error is happend during 20-etcd-service-manager.conf loading. So I have to solve this error at first.

tail -f /var/log/syslog

systemd[1]: kubelet.service: Service hold-off time over, scheduling restart.

systemd[1]: Stopped kubelet: The Kubernetes Node Agent.

systemd[1]: Started kubelet: The Kubernetes Node Agent.

kubelet[28517]: Flag --address has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.

kubelet[28517]: Flag --pod-manifest-path has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.

kubelet[28517]: Flag --allow-privileged has been deprecated, will be removed in a future version

kubelet[28517]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.

systemd[1]: Started Kubernetes systemd probe.

kubelet[28517]: I0522 14:05:31.497808   28517 server.go:417] Version: v1.14.2

kubelet[28517]: I0522 14:05:31.498194   28517 plugins.go:103] No cloud provider specified.

kubelet[28517]: W0522 14:05:31.498229   28517 server.go:556] standalone mode, no API client

kubelet[28517]: W0522 14:05:31.598549   28517 server.go:474] No api server defined - no events will be sent to API server.

kubelet[28517]: I0522 14:05:31.598601   28517 server.go:625] --cgroups-per-qos enabled, but --cgroup-root was not specified.  defaulting to /

kubelet[28517]: F0522 14:05:31.599231   28517 server.go:265] failed to run Kubelet: Running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: [Filename#011#011#011#011Type#011#011Size#011Used#011Priority /dev/sda2  partition#0111996796#0110#011-1]

systemd[1]: kubelet.service: Main process exited, code=exited, status=255/n/a

systemd[1]: kubelet.service: Unit entered failed state.

systemd[1]: kubelet.service: Failed with result 'exit-code'.

There are some error and warning messages. To solve this, I have to create "kubeadmcfg.yaml" from this instruction. In my case, I will difference file name like below

# cat external-etcd-cfg.yaml
apiVersion: "kubeadm.k8s.io/v1beta1"
kind: ClusterConfiguration
controlPlaneEndpoint: 147.75.94.251:6443
etcd:
    local:
        serverCertSANs:
        - "147.75.92.69"
        peerCertSANs:
        - "147.75.92.69"
        extraArgs:
            initial-cluster: e1=https://147.75.92.69:2380
            initial-cluster-state: new
            name: e1
            listen-peer-urls: https://147.75.92.69:2380
            listen-client-urls: https://147.75.92.69:2379
            advertise-client-urls: https://147.75.92.69:2379
            initial-advertise-peer-urls: https://147.75.92.69:2380

"controlPlaneEndpoint: 147.75.94.251:6443" is master IP address and Port for API server. This parameter solve this warning "No api server defined - no events will be sent to API server.". 147.75.92.69 ip address is external etcd node interface IP addresss which is announced for outside. In this yaml file, some options are included. Therefore, I have to revise 20-etcd-service-manager.conf file like below. 

Even if I added more options in yaml file, I do not handle root cause why the kubelet fail. In the syslog, "failed to run Kubelet: Running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false" is the main reason. To solve this, there are 3 option.

# swapoff -a

# vi /etc/fstab

UUID=b7edcf12-2397-489a-bed1-4b5a3c4b1df3       /       ext4    errors=remount-ro       0       1

# UUID=a3babb9d-5aee-4a1d-a894-02aa816ef6e7       none    swap    none    0       0

"swapoff -a" is temporary option. Comment "swap" in "/etc/fstab" is permenant option. Adding " --fail-swap-on=false" in 20-etcd-service-manager.conf is another permenant option. After then, the status of kubelet will be like this.

Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=systemd" 
ExecStart= 
ExecStart=/usr/bin/kubelet --address=0.0.0.0 --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --fail-swap-on=false $KUBELET_EXTRA_ARGS 
Restart=always

Now, I am ready to deploy etcd container deployment. I need certificate and private key for etcd cluster to work well. These values are located in "/etc/kubernetes/pki/etcd". However, you do not have this directory at this time. As the instruction, these file will be generated with command below.

# kubeadm init phase certs etcd-ca
[certs] Generating "etcd/ca" certificate and key
# ls /etc/kubernetes/pki/etcd/
ca.crt  ca.key

If you are want to make cluster of etcd nodes, I have copy these files on each etcd nodes. However, it is not enough to work well. I need more certiface and key.

kubeadm init phase certs etcd-server --config=external-etcd-cfg.yaml

kubeadm init phase certs etcd-peer --config=external-etcd-cfg.yaml

kubeadm init phase certs etcd-healthcheck-client --config=external-etcd-cfg.yaml

kubeadm init phase certs apiserver-etcd-client --config=external-etcd-cfg.yaml

after then, serveral key will be generated. In fact, some of key is not necessary if you run single external etcd node. Now, I can run etcd container with command below

# kubeadm init phase etcd local --config=external-etcd-cfg.yaml

# docker ps
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS               NAMES
f7f427f30a04        2c4adeb21b4f           "etcd --advertise-cl…"   16 minutes ago      Up 16 minutes                           k8s_etcd_etcd-e1_kube-system_9a37a797efa5968588eac7b51458eecc_0
5686bb62b14f        k8s.gcr.io/pause:3.1   "/pause"                 16 minutes ago      Up 16 minutes                           k8s_POD_etcd-e1_kube-system_9a37a797efa5968588eac7b51458eecc_0

 

# docker exec f7f427f30a04 etcdctl --cert-file /etc/kubernetes/pki/etcd/peer.crt --key-file /etc/kubernetes/pki/etcd/peer.key --ca-file /etc/kubernetes/pki/etcd/ca.crt --endpoints https://147.75.92.69:2379 cluster-health
member d3b00bc687dc09ae is healthy: got healthy result from https://147.75.92.69:2379
cluster is healthy

I can also check the health status.

 

 

4. Install master nodes

 

There are 2 instructions for master node, single master and cluser masters. To setup the master node, I need configuration file. I will refer from this instruction. This is the sample configuration yaml file what I have

cat < ./kubeadm-config.yaml

apiVersion: kubeadm.k8s.io/v1beta1

kind: InitConfiguration

localAPIEndpoint:

  advertiseAddress: 147.75.94.251

  bindPort: 6443

---

apiVersion: kubeadm.k8s.io/v1beta1

kind: ClusterConfiguration

kubernetesVersion: v1.14.1

clusterName: crenet-cluster

controlPlaneEndpoint: 147.75.94.251:6443

networking:

  podSubnet: 10.244.0.0/16

controllerManager:

  extraArgs:

    deployment-controller-sync-period: "50s"

---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: ipvs

EOF

With this configuration above, I can run "kubeadm init". Please note that "mode: ipvs" will change the kube-proxy mode to work with "ipvsadm" kerneal module. In the post what I wrote, It will be undertand how kube-proxy work with this part. This is overview to install and load kernal module

apt-get install ipvsadm
echo "net.ipv4.conf.all.arp_ignore=1" >> /etc/sysctl.conf
echo "net.ipv4.conf.all.arp_announce=2" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf

modprobe ip_vs_rr  
modprobe ip_vs_wrr  
modprobe ip_vs_sh 
modprobe ip_vs

Sometimes, some module are not loaded. So I need to do manually with "modeprobe". If these module are not loaed when kubeadm init is started, I can see this message "kernel modules are not loaded: [ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh]

Now, it will load the file "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf".

# cat /etc/systemd//system/kubelet.service.d/10-kubeadm.conf

# Note: This dropin only works with kubeadm and kubelet v1.11+

[Service]

Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"

Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"

Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=systemd"

# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically

EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env

# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use

# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.

EnvironmentFile=-/etc/default/kubelet

ExecStart=

ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

With this configuration I can run "kubeadm init" 

swapoff -a

sudo kubeadm init --config=kubeadm-config.yaml --experimental-upload-certs

before run kubeadm init, I need to "swapoff -a". I can get some error message without "swapoff -a"

[init] Using Kubernetes version: v1.14.1

[preflight] Running pre-flight checks

error execution phase preflight: [preflight] Some fatal errors occurred:

        [ERROR Swap]: running with swap on is not supported. Please disable swap

[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

Anyway, I will get this result when I make master node succefully.

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube

  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.

Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:

  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of the control-plane node running the following command on each as root:

  kubeadm join 147.75.94.251:6443 --token 9nbo8n.y8oke84pmjgaj3px \

    --discovery-token-ca-cert-hash sha256:ac3693f08617ad045bf2e18a1ec0c3240e0651057dcd29e52daa21176a02b9f6 \

    --experimental-control-plane --certificate-key 1eae6218e326a045b866b38e4c0b0135d49203073bfe4f06f602e415dcd9b7a6

Please note that the certificate-key gives access to cluster sensitive data, keep it secret!

As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use

"kubeadm init phase upload-certs --experimental-upload-certs" to reload certs afterward.

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 147.75.94.251:6443 --token 9nbo8n.y8oke84pmjgaj3px \

    --discovery-token-ca-cert-hash sha256:ac3693f08617ad045bf2e18a1ec0c3240e0651057dcd29e52daa21176a02b9f6

I need more steps. First I configure for "kubectl" enable.

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

After this, I can use "kubectl" command. Sometimes, master status can be "NotReady". At this time, I should check the status of pods with "kubectl get pods --all-namespace"

# kubectl get nodes

NAME   STATUS     ROLES    AGE     VERSION

m1     NotReady   master   4m43s   v1.14.2

 

 

From this instruction, I need to POD network to solve this issue.

To install POD network, look at this instuction.

In my case, I will use "Flannel".

echo "net.bridge.bridge-nf-call-iptables=1" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
wget https://raw.githubusercontent.com/coreos/flannel/62e44c867a2846fefb68bd5f178daf4da3095ccb/Documentation/kube-flannel.yml
kubectl apply -f kube-flannel.yml

And then, the master status is normal

# kubectl get pods --all-namespaces

NAMESPACE     NAME                          READY   STATUS    RESTARTS   AGE

kube-system   coredns-fb8b8dccf-627rr       1/1     Running   0          16m

kube-system   coredns-fb8b8dccf-kwvb4       1/1     Running   0          16m

kube-system   etcd-m1                       1/1     Running   0          15m

kube-system   kube-apiserver-m1             1/1     Running   0          15m

kube-system   kube-controller-manager-m1    1/1     Running   0          15m

kube-system   kube-flannel-ds-amd64-6s7xh   1/1     Running   0          54s

kube-system   kube-proxy-gm6bl              1/1     Running   0          16m

kube-system   kube-scheduler-m1             1/1     Running   0          15m

 

# kubectl get nodes

NAME   STATUS   ROLES    AGE   VERSION

m1     Ready    master   17m   v1.14.2

Oh It is work now. See status with more information

# systemctl status kubelet
  kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Wed 2019-05-22 15:44:37 UTC; 1h 29min ago
     Docs: https://kubernetes.io/docs/home/
 Main PID: 1490 (kubelet)
    Tasks: 21
   Memory: 35.9M
      CPU: 4min 37.546s
   CGroup: /system.slice/kubelet.service
           └─1490 /usr/bin/kubelet --fail-swap-on=false --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib

# cat /var/lib/kubelet/config.yaml | grep -i cgroup
cgroupDriver: cgroupfs
cgroupsPerQOS: true

There is something strange. "cgroupDriver: cgroupfs" is strange. It should be "systemd", becuase I update "Environment="KUBELET_EXTRA_ARGS=--cgroup-driver=systemd" in "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf". I think it is not work. I will update for this

# cat kubeadm-config.yaml

apiVersion: kubeadm.k8s.io/v1beta1

kind: InitConfiguration

localAPIEndpoint:

  advertiseAddress: 147.75.94.251

  bindPort: 6443

---

apiVersion: kubeadm.k8s.io/v1beta1

kind: ClusterConfiguration

kubernetesVersion: v1.14.1

clusterName: crenet-cluster

controlPlaneEndpoint: 147.75.94.251:6443

networking:

  podSubnet: 10.244.0.0/16

controllerManager:

  extraArgs:

    deployment-controller-sync-period: "50s"

---

apiVersion: kubelet.config.k8s.io/v1beta1

kind: KubeletConfiguration

cgroupDriver: systemd

------
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: ipvs

I will run "kubeadm reset" and "kubeadm init" again. Now

# cat /var/lib/kubelet/config.yaml | grep -i cgroup
cgroupDriver: systemd

However, this is not all of things. I have alread made external etcd. I have not configure for this yet. Default, etcd conatiner is located on each master node. They are not clustered.

# kubectl get pods --all-namespaces

NAMESPACE     NAME                          READY   STATUS    RESTARTS   AGE

kube-system   coredns-fb8b8dccf-627rr       1/1     Running   0          73m

kube-system   coredns-fb8b8dccf-kwvb4       1/1     Running   0          73m

kube-system   etcd-m1                       1/1     Running   0          72m

kube-system   kube-apiserver-m1             1/1     Running   0          72m

kube-system   kube-controller-manager-m1    1/1     Running   0          72m

kube-system   kube-flannel-ds-amd64-6s7xh   1/1     Running   0          57m

kube-system   kube-proxy-gm6bl              1/1     Running   0          73m

kube-system   kube-scheduler-m1             1/1     Running   0          72m

From this instruction, there are serveral step for this. At first I need to copy the certificate and key from etcd node.

Now, I need to update my configuration file

# cat kubeadm-config.yaml

apiVersion: kubeadm.k8s.io/v1beta1

kind: InitConfiguration

localAPIEndpoint:

  advertiseAddress: 147.75.94.251

  bindPort: 6443

---

apiVersion: kubeadm.k8s.io/v1beta1

kind: ClusterConfiguration

kubernetesVersion: v1.14.1

clusterName: crenet-cluster

controlPlaneEndpoint: 147.75.94.251:6443

networking:

  podSubnet: 10.244.0.0/16

controllerManager:

  extraArgs:

    deployment-controller-sync-period: "50s"

etcd:

    external:

        endpoints:

        - https://147.75.92.69:2379

        caFile: /etc/kubernetes/pki/etcd/ca.crt

        certFile: /etc/kubernetes/pki/apiserver-etcd-client.crt

        keyFile: /etc/kubernetes/pki/apiserver-etcd-client.key

---

apiVersion: kubelet.config.k8s.io/v1beta1

kind: KubeletConfiguration

cgroupDriver: systemd

---

---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: ipvs

Now, I will run "kubeadm reset" and "kubeadm init" again. Please note that the certificate and key will be remove when I run kubeadm reset. Therefore, I need to copy again from etcd node

error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR ExternalEtcdVersion]: couldn't load external etcd's server certificate /etc/kubernetes/pki/etcd/ca.crt: open /etc/kubernetes/pki/etcd/ca.crt: no such file or directory
        [ERROR ExternalEtcdClientCertificates]: /etc/kubernetes/pki/etcd/ca.crt doesn't exist
        [ERROR ExternalEtcdClientCertificates]: /etc/kubernetes/pki/apiserver-etcd-client.crt doesn't exist
        [ERROR ExternalEtcdClientCertificates]: /etc/kubernetes/pki/apiserver-etcd-client.key doesn't exist
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

After I copy the certificate and key, I can check the status again

# kubectl get pods --all-namespaces

NAMESPACE     NAME                          READY   STATUS    RESTARTS   AGE

kube-system   coredns-fb8b8dccf-nzv2s       0/1     Running   0          2m30s

kube-system   coredns-fb8b8dccf-v74jz       0/1     Running   0          2m30s

kube-system   kube-apiserver-m1             1/1     Running   0          113s

kube-system   kube-controller-manager-m1    1/1     Running   0          92s

kube-system   kube-flannel-ds-amd64-6sqzv   1/1     Running   0          18s

kube-system   kube-proxy-s6sj7              1/1     Running   0          2m29s

kube-system   kube-scheduler-m1             1/1     Running   0          94s

etcd is not existed on master node. 

 

5. Setup the Worker nodes

 

It is almost same. I need docker engin and kubeadm, kubectl, kubelet. I have already explain about these above. After creating master node, I can see the message like below

 kubeadm join 147.75.94.251:6443 --token 9nbo8n.y8oke84pmjgaj3px \

    --discovery-token-ca-cert-hash sha256:ac3693f08617ad045bf2e18a1ec0c3240e0651057dcd29e52daa21176a02b9f6 \

    --experimental-control-plane --certificate-key 1eae6218e326a045b866b38e4c0b0135d49203073bfe4f06f602e415dcd9b7a6

 

kubeadm join 147.75.94.251:6443 --token 9nbo8n.y8oke84pmjgaj3px \

    --discovery-token-ca-cert-hash sha256:ac3693f08617ad045bf2e18a1ec0c3240e0651057dcd29e52daa21176a02b9f6

First is for adding master node, second is for adding worker node. I need some information such as token.

# kubeadm token list

TOKEN                     TTL       EXPIRES                USAGES                   DESCRIPTION                                           EXTRA GROUPS

seiuxa.fsaa2107s0vl10kg   1h        2019-05-22T19:27:32Z                      Proxy for managing TTL for the kubeadm-certs secret   

yo0mwz.5mc41r1gn90akio2   23h       2019-05-23T17:27:33Z   authentication,signing                                                   system:bootstrappers:kubeadm:default-node-token

 

# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | \

>    openssl dgst -sha256 -hex | sed 's/^.* //'

aeebcc777388b5ecde64801a51d2e37cf7ff2410e8e64f1832694fc3946d7c27

With these values, I can run command on each worker node. I will check the status of the cluster.

# kubectl get nodes

NAME   STATUS   ROLES    AGE   VERSION

m1     Ready    master   24m   v1.14.2

w1     Ready       39s   v1.14.2

w2     Ready       36s   v1.14.2

Now I made the kubernetes cluster.

 

Reference

[ 1 ] https://kubernetes.io/docs/setup/independent/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl

[ 2 ] https://docs.docker.com/install/linux/docker-ce/ubuntu/

[ 3 ] https://kubernetes.io/docs/setup/cri/

[ 4 ] https://kubernetes.io/docs/setup/independent/setup-ha-etcd-with-kubeadm/ 

[ 5 ] https://createnetech.tistory.com/17?category=679927

[ 6 ] https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

[ 7 ] https://kubernetes.io/docs/setup/independent/high-availability/

[ 8 ] https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1

[ 9 ] https://kubernetes.io/docs/setup/independent/troubleshooting-kubeadm/#coredns-or-kube-dns-is-stuck-in-the-pending-state

[ 10 ] https://kubernetes.io/docs/setup/independent/high-availability/#external-etcd-nodes

[ 11 ] https://createnetech.tistory.com/36?category=672585

[ 12 ] https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/#is-kube-proxy-writing-iptables-rules

'Network Engineering > Docker and Kubernetes Learning' 카테고리의 다른 글

How does the flannel work?  (0) 2019.01.09

How install oracle 11g on Windows 2012 R2?  (Enable archive log and Supplemental log)?

 

Recently, I need to learn the oracle to migrate data from on-prem to aws. In fact, I am not the DBA, therefore, I can not handle deep dive. I hope the I can help someone like me who is the first time about oracle.

 

1. Pre-requsite.

 

I have Windows 2012 R2 which supports oracle database 11g. For successful installation, I need the ".Netframe 3.5" installed. In server manager. Click "Add Roles and Features" at first.

In Features, choose the ".NET Framework 3.5 Feature" and Install this.

After then, I am ready to install oracle database.

 

2. Install oracle database.

 

The reason why I select Windows is simple to consist rather than Linux. I will follow two instructions mainly. https://www.youtube.com/watch?v=YgFfjLHY-wE is helpful for me. At the beginning, I need installation file. I can download from oralce site.

In my case, I will download "Microsoft Windows (X64)". There are two files. After extract both of files, I need to merge and make together in same directory. I copied and pasted whole directory from secondary to first.

After merge, I can see the directory inside. There is the "setup" icon. Click it.

Click Run and Start Installation for oracle database.

Depends on the system environments, Installer make warnning messages like this. However, I can ignore this, Click "yes"

Uncheck "I wish to receive security updates via My Oracle support", because I do not need this feature. It does not matter for next step. In email field, I can leave with empty. Just click "Next"

After Next, the warning message come. However it is also not matter for next step. Just click "yes".

Choose "Create and configure as a database". Because this is first installtion on this server. Click "Next".

In my case, my operating system is windows 2012 R2 server. Therefore, I will choose "Sever class".

I will install with standalone mode. Choose "single instance database installation" and click "Next".

Choose "Advanced Install" and Next.

This step is more important rather than before. In this insturction, there are some explain about the fields. I overview about below. 

Select "Langurage"

I will select "Standard Edition One" (Please note I can select what I want as the oracle database engine).

I select my custom home directory like below.

Select configuration type. In my case, I will choose genera purpose.

"Global database name" is not SID. However, I choosed single instance mode. Becuase of this, the SID can be same as Global database name. However, I can make different in Advanced mode.

 

I will adjust some paramters for memory, characters set, security and sample schema.

I will UTF-8 for character sets.

I will not make sample schema. Un-check "Create database with sample schema"

During this installation, Oracle Enterprise Manager will be installed, even if I do not want. Just click Next

Select File system. Usually it is better to seperate from root disk.

This is the back up configuration. I don't want this at this time.

When I select "Typical Installation". There are Administrative password which is default password for schema (=users)

However, In Advanced mode, I can set password individually like below.

 

If you use simple password, the warnning message happen like below. In my case, this is test oracle database. I will ignore this. Click yes.

In advaced mode
In typical mode

This is summary, Click Finish to installation.

During installation, I can see the configuration assistant process like below.

During the installation, warnning message like below can be occure. In this case, I need to set variable in windows.

I will handle this later. At this time, just click next. I registered the "Administrative password" before. I have told it will be used as default password. However, I have another change to set the password for each schema (=user).

Click Password Management. I will set individual password for "SYS" and "SYSTEM". If you want more, you can set the password more. In oracle database, there are serveral sample test schema such as "HR" and "SCOTT".

Continue with Yes.

 

3. Access database

 

Now, I can access database. At this time, I can use sqlplus which is installed with.

I can access with SYSTEM schema account like below

4. Verify the oracle environment for enterprise manager.

 

During the installation, I see warning message below. Because of this, I need to check environment variables.

In this page, I need to check the status with "emctl status dbconsole"

In this case, I need to set environment value. Properties > Advanced system settings.

In Advanced tap, there are environment value button.

I will add some values in User vriables for Administrator.

For the first issue, I will add "ORACLE_UNQNAME". 

I will reference the value from db_unique_name. In fact, there is value when environment is not set. run "select name,db_unique_name from v$database;".

I will try again "emctl status dbconsole". At this time, there is "Not found" error. 

Go into the directory. Thre is no localhost. Instead, 11.0.0.131 is existed.

To resolve this, I will add "ORACLE_HOSTNAME" like below.

After then, It will be like below. This is normal. However, It look like not perfect. "EM Daemon is not running" is happen.

I followed this video. To make success, I have to start service manually. At this time, I can not start after right button.

Find the file below. In emd properites file, "agentTZRegion=+06:00" should be adjusted with OS time.

I adjust the time 

Now, I can use this.

 

5. Oralce database stop, start and restart

 

In this instruction, there are several way to stop and start. In this part, I will overview sqlplus to stop and start.

6. Enable/Disable Archive log Mode

 

Sometime, it is necessary to enable this feature. It is utilized to synchronize databases with log-miner. For this, I will follow this instruction. run "archive log list". The result is displaied. It is not enabled default.

I need to shutdown with "shutdown immediate". My status is changed to "nolog".

I have to change the status to "mount", which I can change configuration on. Run "startup mount".

Run "alter database archivelog;" to enable

After then, I open the database "alter database open;"

If you want to disable, I use "alter database noarchivelog;"

 

7. Enable/Disable supplemental logging 

 

This action should be done in database. To check the status, run "select supplemental_log_data_min from v$database;"

To enable and disable, run query like below.

This is the basic configuration for the installation. 

 

Reference 

 

[ 1 ] https://www.youtube.com/watch?v=YgFfjLHY-wE

[ 2 ] https://medium.com/@Dracontis/how-to-install-oracle-11g-database-on-windows-server-2012-a4d30d4dc727

[ 3 ] https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

[ 4 ] https://docs.oracle.com/cd/E25178_01/server.1111/e10897/install.htm

[ 5 ] http://www.dba-oracle.com/t_oracle_unqname.htm

[ 6 ] http://blog.mclaughlinsoftware.com/2012/08/23/whats-oracle_unqname/

[ 7 ] https://www.youtube.com/watch?v=Y8i41J7aLwo

[ 8 ] https://docs.oracle.com/cd/B14117_01/win.101/b10113/admin.htm#CDCEJADC

[ 9 ] http://www.oracledistilled.com/oracle-database/backup-and-recovery/enabledisable-archive-log-mode-10g11g/

 

 

 

How to user the Oracle View and Joins (Inner and outer)

 

Recently, I have been studying about the Oracle Database. In this post, I wrote about the basic concept. In this post, I will handle about View and Joins.

 

1. Pre-requisite

 

I will create 2 tables like below.

create table MYADMIN.users ( name varchar2(15), id number(10) ) tablespace myspace;
create table MYADMIN.lessons ( id number(10), lessons varchar2(15), day varchar2(15) ) tablespace myspace;

insert into MYADMIN.users (name, id) values ( 'ant', 101 );
insert into MYADMIN.users (name, id) values ( 'bee', 102 );
insert into MYADMIN.users (name, id) values ( 'dog', 104 );


insert into MYADMIN.lessons (id, lessons, day) values ( 101, 'math', 'monday' );
insert into MYADMIN.lessons (id, lessons, day) values ( 102, 'art', 'tuseday' );
insert into MYADMIN.lessons (id, lessons, day) values ( 103, 'music', 'friday' );
insert into MYADMIN.lessons (id, lessons, day) values ( 105, 'exec', 'sunday' );

After run these command, I can get the tables with datas

 

Now, I am ready to start.

 

2. Inner and  Right, Left, Full Joins

 

I will follow this instructions. In this instructions, It has more detail. In this post, I will handle the way how to use this. Joins are one of filters with tables. Therefore, I can extract the matched data from tables.

 

2-1. Inner Join

 

As the figure, It shows the result after Inner Join. I can extract the matched data as intersection. This is the command. 

select name from MYADMIN.users inner join MYADMIN.lessons on MYADMIN.users.id = MYADMIN.lessons.id; 

This command means that I can extract intersection from both of "MYADMIN.users" table and "MYADMIN.lessons" table.

 

 

2-2. Left outer Join

 

With this option, Left side of tables are the source. This source start to compare data of the Right side of tables. When condition is matched. It extract matched data from both of table. However, the condition is not matched, the data from the source can be obtained but the data from right side of table inserted as the "<null>"

select MYADMIN.users.name, MYADMIN.lessons.day from MYADMIN.users left outer join MYADMIN.lessons on MYADMIN.users.id = MYADMIN.lessons.id; 

 

2-3. Right outer Join

This is reverse concept of the left outer join above. At this time, left side of tables is the source. Therefore, the value could be "<null>" from right side of tables, when condition does not match.

select MYADMIN.users.name, MYADMIN.lessons.day from MYADMIN.users right outer join MYADMIN.lessons on MYADMIN.users.id = MYADMIN.lessons.id; 

2-4. Full outer Join

With this option, left side and right side can be source. If the column from left side which does not exist in right side, this is the source. If the column from right side which does not exist in left side, this is also the source.  

select MYADMIN.users.name, MYADMIN.lessons.day from MYADMIN.users full outer join MYADMIN.lessons on MYADMIN.users.id = MYADMIN.lessons.id; 

 

3. Views

 

I will follow this instruction for this part. Views is the virtual table which is not existed in real. Sometime, I need to combine or make complex database query. In this case, this views is quite useful. For example, I will create view with the query of full outer join.

# create view

create view matched_info as select MYADMIN.users.name, MYADMIN.lessons.day from MYADMIN.users full outer join MYADMIN.lessons on MYADMIN.users.id = MYADMIN.lessons.id;

 

# select for query

select * from matched_info; 

I have already told that the view is not real table. Thus, I can not find out the information from "user_tables".

However, I can see the view information from "user_views". In the "TEXT", I can see the query which I used to create.

I think "the views is belonged to the schema (=user), even if it is virtual table". I can give some grant option like below.

grant select on MYADMIN.matched_info to MYUSER;

 

After login again with "MYUSER" account, I can show the data from this view also.

However, I can not show any detail information with "user_views" or "user_table".

Because, it only show the data whch is created by "schema". Therefore, if you want to see, you need to search through grant option like below.

If I want delete (drop) the view, Use this command below

drop view MYADMIN.matched_info;

 

Reference 

 

[ 1 ] https://www.techonthenet.com/oracle/joins.php

[ 2 ] https://createnetech.tistory.com/32

[ 3 ] https://www.techonthenet.com/oracle/views.php

 

+ Recent posts