Tuesday, November 20, 2018

Highly Available Clusters with kubeadm

In CentOs 7, we´ll install Kubernetes with the following command:

yum install - and kubernetes etcd

For it to work, we must have the Centos-Extras repository enabled.

Once the packages are installed we can start booting services.

Booting services in the Master

systemctl start etcd
systemctl start kube-controller-manager
systemctl start kube-scheduler
systemctl start kube-apiserver

Start-up of the services in each of the nodes

systemctl start docker
systemctl start kube-proxy
systemctl start kubelet

you will notice that a new network interface called docker0 has been created.



POD Configuration

We will create a file in JSON format like the one below. If you remember, in the article Installation and configuration of Dockers (Containers) in Centos 7 we already downloaded the Apache container, so we will use it to configure the POD.

This time, I will start it in the local port 9090, since for the 8080 I have another service listening:

root@Centos7 kubernetes]# docker run -dit -name apachetest -p 9090:80 -v /tmp/ws/:/usr/local/apache2/htdocs/ httpd
7983a74eee23fa59abd434ad5107896e2b2a1a5b9539c5770e6d1c8549eeb060
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7983a74eee23 httpd "httpd-foreground" About a minute ago Up About a minute 0.0.0.0:9090->80/tcp apachetest
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# curl -s http://localhost:9090
<html>
<body>
I'm a container
</body>
</html>
[root@Centos7 kubernetes]#
The JSON file would be as follows:
[root@Centos7 kubernetes]# cat container-httpd-rc.json
{ "kind": "ReplicationController",
"apiVersion": "v1″,
"metadata":{ "name": "apachepod-controller" },
"spec":{
"replicas":3,
"selector":{ "name": "apachepod" },
"template:{
"metadata":{
"labels":{ "name": "apachepod" }
},
"spec":{
"containers:[ {
"name": "apachepod",
"image": "docker.io/httpd",
"ports:[ {
"containerPort":80,
"protocol": "TCP"
} ]
} ]
}
}
}
}
[root@Centos7 kubernetes]#
Next, we apply the settings:
- If we haven't previously created a key, we have to create it for the first time:
[root@Centos7 kubernetes]# openssl genrsa -out /tmp/serviceaccount.key 2048
Generating RSA private key, 2048 bit long modulus
……………………….+++
……………………………………………………+++
e is 65537 (0x10001)

We edit the file /etc/kubernetes/apiserver, adding:

KUBE_API_ARGS="-service_account_key_file=/tmp/serviceaccount.key"
We edit the file /etc/kubernetes/controller-manager, adding:
KUBE_CONTROLLER_MANAGER_ARGS="-service_account_private_key_file=/tmp/serviceaccount.key"

We restart the Kubernetes service:

root@Centos7 kubernetes]# systemctl restart etcd
[root@Centos7 kubernetes]# systemctl restart kube-controller-manager
[root@Centos7 kubernetes]# systemctl restart kube-scheduler
[root@Centos7 kubernetes]# systemctl restart kube-apiserver
[root@Centos7 kubernetes]#

- Once the key is generated, we can finally create our POD from the previously created JSON file:

[root@Centos7 kubernetes]# kubectl create -f container-httpd-rc.json
replicationcontroller "apachepod-controller" created
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# kubectl get pod
NAME READY STATUS RESTARTS AGE
apachepod-controller-10xv7 0/1 Pending 0 50s
apachepod-controller-dx8nr 0/1 Pending 0 50s
apachepod-controller-nm5k4 0/1 Pending 0 50s
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# kubectl get replicationcontrollers
NAME DESIRED CURRENT READY AGE
apachepod-controller 3 3 0 1m
[root@Centos7 kubernetes]#
If you wish, you can scale the number of PODs in real time:
root@Centos7 kubernetes]# kubectl scale rc apachepod-controller -replicas=4
replicationcontroller "apachepod-controller" scaled
[root@Centos7 kubernetes]# kubectl get replicationcontrollers
NAME DESIRED CURRENT READY AGE
apachepod-controller 4 4 0 2m
[root@Centos7 kubernetes]# kubectl get pod
NAME READY STATUS RESTARTS AGE
apachepod-controller-10xv7 0/1 Pending 0 3m
apachepod-controller-dx8nr 0/1 Pending 0 3m
apachepod-controller-ksrdc 0/1 Pending 0 14s
apachepod-controller-nm5k4 0/1 Pending 0 3m
[root@Centos7 kubernetes]#

Creation of the nodes that will form part of the kubernetes cluster:

[root@Centos7 kubernetes]# cat nodes.json
{
"kind": "Node",
"apiVersion": "v1",
"metadata": {
"name": "10.0.0.2",
"labels: {
"environment: production,
"name": "kubernete1"
}
}
}
{
"kind": "Node",
"apiVersion": "v1",
"metadata": {
"name": "10.0.0.3",
"labels: {
"environment: production,
"name": "kubernete2"
}
}
}
[root@Centos7 kubernetes]#
[root@Centos7 kubernetes]# kubectl create -f nodes.json
node "10.0.0.2" created
node "10.0.0.3" created
[root@Centos7 kubernetes]#

Thursday, April 26, 2018

Two ways to create mksysb images in AIX


1) create on NIM server command: 

nim -o define -t mksysb -a server=master -a source=<server name> -a mk_image=yes -a location=<location of the store image> <mksysb image name> 

This will create the mksysb image of the client server and define it on the NIM server. 

Example: 
nim -o define -t mksysb -a server=master -a source=edppbuslvd01 -a mk_image=yes -a location=/nim/mksysb/edppbuslvd01_6100-04-03-05112010 edppbuslvd01_6100-04-03-05112010 

server=master: server to store image, in this case is master 
source=edppbuslvd01: the source of the image, which is client 
location: the location of the stored mksysb image 


2) create on client machine and then copy to NIM server and define on NIM server, or NFS mount the filesystem from NIM server on the client server. 

let say you successfully NFS mount nim server filesystem on the client machine as /mnt. 

mksysb -ieX /mnt/edppbuslvd01_6100-04-03-05112010 


-e: exclude the filesystem/dir that defined on /etc/exclude.rootvg 
-i: call the mkszfile command to generate the /image.data file 
The /image.data file contains information on volume groups, logical volumes, file systems, paging space, and physical volumes.
 This information is included in the backup for future use by the installation process. 
-X: set to automatically expand the /tmp if necessary 

After the mksysb image created, you need to define it on NIM server. 

nim -o define -t mksysb -a server=master -a location=<image location> <image name>