Instruction Kubernetes
Instruction Kubernetes
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
Then you can join any number of worker nodes by running the following on each as
root:
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
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
Useful links:
https://www.linode.com/docs/quick-answers/linux/how-to-change-selinux-modes/
https://www.linuxtechi.com/install-kubernetes-1-7-centos7-rhel7/
Creating POD
Create the yaml file for pod as
root@KubeMaster:~/kuberentespract# vi my-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: myapp
spec:
containers:
- name: myapp-conatiner
image: busybox
command: ['sh','-c', 'echo hello kubernetes! && sleep 3600']
root@KubeMaster:~/kuberentespract# kubectl create -f my-pod.yml
pod/my-pod created
root@KubeMaster:~/kuberentespract#
root@KubeMaster:~/kuberentespract# kubectl get pod
NAME READY STATUS RESTARTS AGE
my-pod 1/1 Running 0 96s
root@KubeMaster:~/kuberentespract#
To edit the pod use below commands
root@KubeMaster:~/kuberentespract# vi my-pod.yml
root@KubeMaster:~/kuberentespract# kubectl apply -f my-pod.yml
root@KubeMaster:~/kuberentespract# kubectl edit pod my-pod
Namespaces
root@KubeMaster:~/kuberentespract# vi my-pod-ns.yml
root@KubeMaster:~/kuberentespract# kubectl create -f my-pod-ns.yml