Saturday, August 3, 2019

Kubernetes

~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        475M     0  475M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  444K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  1.4G  6.7G  17% /
tmpfs            99M     0   99M   0% /run/user/1000
tmpfs            99M     0   99M   0% /run/user/0
[ec2-user@ip-172-31-36-115 ~]$ clear
[ec2-user@ip-172-31-36-115 ~]$ history
    1  clear
    2  ssh -i "vm3key.pem" ec2-user@ec2-54-88-73-115.compute-1.amazonaws.com
    3  clear
    4  date
    5  aws configure
    6  curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
    7  $curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl
    8  curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl
    9  chmod +x ./kubectl
   10  sudo mv ./kubectl /usr/local/bin/kubectl
   11  kubectl version
   12  bucket_name=sample-kops-state-storesriram17m
   13  export KOPS_STATE_STORE=s3://${bucket_name}
   14  kops create cluster --state=${KOPS_STATE_STORE} --node-count=2 --master-size=t2.micro --node-size=t2.micro --zones=us-east-1a --name=${KOPS_CLUSTER_NAME}
   15  kops version
   16  curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
   17  chmod +x kops-linux-amd64
   18  sudo mv kops-linux-amd64 /usr/local/bin/kops
   19  kops version
   20  kops create cluster --state=${KOPS_STATE_STORE} --node-count=2 --master-size=t2.micro --node-size=t2.micro --zones=us-east-1a --name=${KOPS_CLUSTER_NAME}
   21  kubectl version
   22  bucket_name=sample-kops-state-storesriram17m
   23  aws s3 mb s3://${bucket_name} --region us-east-1
   24  export KOPS_CLUSTER_NAME=test17m.tk
   25  export KOPS_STATE_STORE=s3://${bucket_name}
   26  kops create cluster --state=${KOPS_STATE_STORE} --node-count=2 --master-size=t2.micro --node-size=t2.micro --zones=us-east-1a --name=${KOPS_CLUSTER_NAME}
   27  clear
   28  df-h
   29  df -h
   30  clear
   31  df -h
   32  clear
   33  history
[ec2-user@ip-172-31-36-115 ~]$ kops create cluster --state=${KOPS_STATE_STORE} --node-count=2 --master-size=t2.micro --node-size=t2.micro --zones=us-east-1a --name=${KOPS_CLUSTER_NAME}
I0804 03:23:23.333500    3650 create_cluster.go:519] Inferred --cloud=aws from zone "us-east-1a"
I0804 03:23:23.382236    3650 subnets.go:184] Assigned CIDR 172.20.32.0/19 to subnet us-east-1a

error determining default DNS zone: No matching hosted zones found for ".test17m.tk"; please create one (e.g. "test17m.tk") first
[ec2-user@ip-172-31-36-115 ~]$ kops create cluster --state=${KOPS_STATE_STORE} -                                                      -node-count=2 --master-size=t2.micro --node-size=t2.micro --zones=us-east-1a --n                                                      ame=${KOPS_CLUSTER_NAME}
I0804 03:28:05.278469    3656 create_cluster.go:519] Inferred --cloud=aws from z                                                      one "us-east-1a"
I0804 03:28:05.336537    3656 subnets.go:184] Assigned CIDR 172.20.32.0/19 to su                                                      bnet us-east-1a
Previewing changes that will be made:


********************************************************************************                                                      *

A new kubernetes version is available: 1.12.9
Upgrading is recommended (try kops upgrade cluster)

More information: https://github.com/kubernetes/kops/blob/master/permalinks/upgr                                                      ade_k8s.md#1.12.9

********************************************************************************                                                      *


SSH public key must be specified when running with AWS (create with `kops create                                                       secret --name test17m.tk sshpublickey admin -i ~/.ssh/id_rsa.pub`)
[ec2-user@ip-172-31-36-115 ~]$ kops upgrade cluster

No upgrade required
[ec2-user@ip-172-31-36-115 ~]$ `kops create                                                       secret --name test17m.tk sshpublickey admin -i ~/.ssh/id_rsa.pub`

error reading SSH public key /home/ec2-user/.ssh/id_rsa.pub: open /home/ec2-user/.ssh/id_rsa.pub: no such file or directory
[ec2-user@ip-172-31-36-115 ~]$ pwd
/home/ec2-user
[ec2-user@ip-172-31-36-115 ~]$ kops get cluster
NAME            CLOUD   ZONES
test17m.tk      aws     us-east-1a
[ec2-user@ip-172-31-36-115 ~]$ kops update cluster --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE} --yes

*********************************************************************************

A new kubernetes version is available: 1.12.9
Upgrading is recommended (try kops upgrade cluster)

More information: https://github.com/kubernetes/kops/blob/master/permalinks/upgrade_k8s.md#1.12.9

*********************************************************************************


SSH public key must be specified when running with AWS (create with `kops create secret --name test17m.tk sshpublickey admin -i ~/.ssh/id_rsa.pub`)
[ec2-user@ip-172-31-36-115 ~]$ kops create secret --name test17m.tk sshpublickey admin -i ~/.ssh/id_rsa.pub

error reading SSH public key /home/ec2-user/.ssh/id_rsa.pub: open /home/ec2-user/.ssh/id_rsa.pub: no such file or directory
[ec2-user@ip-172-31-36-115 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ec2-user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ec2-user/.ssh/id_rsa.
Your public key has been saved in /home/ec2-user/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:AwZlcOrXfBFe+1ZGdXoTJU80bcC8Uaqtv1J7Qb9GGNc ec2-user@ip-172-31-36-115.ec2.internal
The key's randomart image is:
+---[RSA 2048]----+
|    oo+   . .oo*%|
|     =   . o .+B*|
|    . o   o . o=*|
|   . . +   . =.*E|
|    . . S . . O .|
|     .   o   +.o.|
|            ....o|
|            ...o.|
|             .+o |
+----[SHA256]-----+
[ec2-user@ip-172-31-36-115 ~]$ kops create secret --name test17m.tk sshpublickey admin -i ~/.ssh/id_rsa.pub
[ec2-user@ip-172-31-36-115 ~]$ kops update cluster --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE} --yes

*********************************************************************************

A new kubernetes version is available: 1.12.9
Upgrading is recommended (try kops upgrade cluster)

More information: https://github.com/kubernetes/kops/blob/master/permalinks/upgrade_k8s.md#1.12.9

*********************************************************************************

I0804 03:35:31.581464    3736 executor.go:103] Tasks: 0 done / 85 total; 43 can run
I0804 03:35:32.559761    3736 vfs_castore.go:729] Issuing new certificate: "apiserver-aggregator-ca"
I0804 03:35:32.642589    3736 vfs_castore.go:729] Issuing new certificate: "etcd-manager-ca-events"
I0804 03:35:32.872741    3736 vfs_castore.go:729] Issuing new certificate: "etcd-peers-ca-events"
I0804 03:35:33.234026    3736 vfs_castore.go:729] Issuing new certificate: "ca"
I0804 03:35:33.450963    3736 vfs_castore.go:729] Issuing new certificate: "etcd-peers-ca-main"
I0804 03:35:33.516532    3736 vfs_castore.go:729] Issuing new certificate: "etcd-manager-ca-main"
I0804 03:35:33.637833    3736 vfs_castore.go:729] Issuing new certificate: "etcd-clients-ca"
I0804 03:35:33.865439    3736 executor.go:103] Tasks: 43 done / 85 total; 24 can run
I0804 03:35:34.476809    3736 vfs_castore.go:729] Issuing new certificate: "apiserver-proxy-client"
I0804 03:35:35.181001    3736 vfs_castore.go:729] Issuing new certificate: "kube-scheduler"
I0804 03:35:35.762033    3736 vfs_castore.go:729] Issuing new certificate: "kops"
I0804 03:35:35.995843    3736 vfs_castore.go:729] Issuing new certificate: "kubecfg"
I0804 03:35:36.140789    3736 vfs_castore.go:729] Issuing new certificate: "kubelet-api"
I0804 03:35:36.194325    3736 vfs_castore.go:729] Issuing new certificate: "kube-controller-manager"
I0804 03:35:36.656187    3736 vfs_castore.go:729] Issuing new certificate: "apiserver-aggregator"
I0804 03:35:36.806476    3736 vfs_castore.go:729] Issuing new certificate: "kube-proxy"
I0804 03:35:36.883589    3736 vfs_castore.go:729] Issuing new certificate: "master"
I0804 03:35:37.007226    3736 vfs_castore.go:729] Issuing new certificate: "kubelet"
I0804 03:35:37.236723    3736 executor.go:103] Tasks: 67 done / 85 total; 16 can run
I0804 03:35:37.478119    3736 launchconfiguration.go:364] waiting for IAM instance profile "nodes.test17m.tk" to be ready
I0804 03:35:37.543176    3736 launchconfiguration.go:364] waiting for IAM instance profile "masters.test17m.tk" to be ready
I0804 03:35:47.891791    3736 executor.go:103] Tasks: 83 done / 85 total; 2 can run
I0804 03:35:48.556292    3736 executor.go:103] Tasks: 85 done / 85 total; 0 can run
I0804 03:35:48.556411    3736 dns.go:153] Pre-creating DNS records
I0804 03:35:48.768540    3736 update_cluster.go:291] Exporting kubecfg for cluster
kops has set your kubectl context to test17m.tk

Cluster is starting.  It should be ready in a few minutes.

Suggestions:
 * validate cluster: kops validate cluster
 * list nodes: kubectl get nodes --show-labels
 * ssh to the master: ssh -i ~/.ssh/id_rsa admin@api.test17m.tk
 * the admin user is specific to Debian. If not using Debian please use the appropriate user based on your OS.
 * read about installing addons at: https://github.com/kubernetes/kops/blob/master/docs/addons.md.

[ec2-user@ip-172-31-36-115 ~]$ kops update cluster --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE} --yes^C
[ec2-user@ip-172-31-36-115 ~]$ kops validate cluster --state=${KOPS_STATE_STORE} --name=${KOPS_CLUSTER_NAME}
Validating cluster test17m.tk

INSTANCE GROUPS
NAME                    ROLE    MACHINETYPE     MIN     MAX     SUBNETS
master-us-east-1a       Master  t2.micro        1       1       us-east-1a
nodes                   Node    t2.micro        2       2       us-east-1a

NODE STATUS
NAME    ROLE    READY

VALIDATION ERRORS
KIND    NAME            MESSAGE
dns     apiserver       Validation Failed

The dns-controller Kubernetes deployment has not updated the Kubernetes cluster's API DNS entry to the correct IP address.  The API DNS IP address is the placeholder address that kops creates: 203.0.113.123.  Please wait about 5-10 minutes for a master to start, dns-controller to launch, and DNS to propagate.  The protokube container and dns-controller deployment logs may contain more diagnostic information.  Etcd and the API DNS entries must be updated for a kops Kubernetes cluster to start.

Validation Failed
[ec2-user@ip-172-31-36-115 ~]$ kops validate cluster --state=${KOPS_STATE_STORE}                                                       --name=${KOPS_CLUSTER_NAME}
Validating cluster test17m.tk

INSTANCE GROUPS
NAME                    ROLE    MACHINETYPE     MIN     MAX     SUBNETS
master-us-east-1a       Master  t2.micro        1       1       us-east-1a
nodes                   Node    t2.micro        2       2       us-east-1a

NODE STATUS
NAME    ROLE    READY

VALIDATION ERRORS
KIND    NAME            MESSAGE
dns     apiserver       Validation Failed

The dns-controller Kubernetes deployment has not updated the Kubernetes cluster'                                                      s API DNS entry to the correct IP address.  The API DNS IP address is the placeh                                                      older address that kops creates: 203.0.113.123.  Please wait about 5-10 minutes                                                       for a master to start, dns-controller to launch, and DNS to propagate.  The prot                                                      okube container and dns-controller deployment logs may contain more diagnostic i                                                      nformation.  Etcd and the API DNS entries must be updated for a kops Kubernetes                                                       cluster to start.

Validation Failed
[ec2-user@ip-172-31-36-115 ~]$ kops validate cluster --state=${KOPS_STATE_STORE} --name=${KOPS_CLUSTER_NAME}
Validating cluster test17m.tk

INSTANCE GROUPS
NAME                    ROLE    MACHINETYPE     MIN     MAX     SUBNETS
master-us-east-1a       Master  t2.micro        1       1       us-east-1a
nodes                   Node    t2.micro        2       2       us-east-1a

NODE STATUS
NAME    ROLE    READY

VALIDATION ERRORS
KIND    NAME            MESSAGE
dns     apiserver       Validation Failed

The dns-controller Kubernetes deployment has not updated the Kubernetes cluster's API DNS entry to the correct IP address.  The API DNS IP address is the placeholder address that kops creates: 203.0.113.123.  Please wait about 5-10 minutes for a master to start, dns-controller to launch, and DNS to propagate.  The protokube container and dns-controller deployment logs may contain more diagnostic information.  Etcd and the API DNS entries must be updated for a kops Kubernetes cluster to start.

Validation Failed
[ec2-user@ip-172-31-36-115 ~]$ kops validate cluster --state=${KOPS_STATE_STORE} --name=${KOPS_CLUSTER_NAME}
Validating cluster test17m.tk

INSTANCE GROUPS
NAME                    ROLE    MACHINETYPE     MIN     MAX     SUBNETS
master-us-east-1a       Master  t2.micro        1       1       us-east-1a
nodes                   Node    t2.micro        2       2       us-east-1a

NODE STATUS
NAME                            ROLE    READY
ip-172-20-42-121.ec2.internal   master  True
ip-172-20-43-186.ec2.internal   node    True
ip-172-20-48-165.ec2.internal   node    True

Your cluster test17m.tk is ready
[ec2-user@ip-172-31-36-115 ~]$ date
Sun Aug  4 03:47:28 UTC 2019
[ec2-user@ip-172-31-36-115 ~]$ kubectl cluster-info
Kubernetes master is running at https://api.test17m.tk
KubeDNS is running at https://api.test17m.tk/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[ec2-user@ip-172-31-36-115 ~]$ ssh -i ~/.ssh/id_rsa admin@api.test17m.tk
The authenticity of host 'api.test17m.tk (3.91.1.165)' can't be established.
ECDSA key fingerprint is SHA256:j1WdbQpHLWdsxajZ0XXUdchLnotSWP3ya+Yb5HrHV60.
ECDSA key fingerprint is MD5:fd:dc:c0:12:6e:6e:2d:62:6c:5c:99:c6:f3:59:2e:fb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'api.test17m.tk,3.91.1.165' (ECDSA) to the list of known hosts.
Linux ip-172-20-42-121 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
admin@ip-172-20-42-121:~$ kubectl create -f https://raw.githubusercontent.com/javahometech/kubernetes/master/pods/pods.yml
pod/nodeapp created
admin@ip-172-20-42-121:~$ kubectl get pods
NAME      READY   STATUS              RESTARTS   AGE
nodeapp   0/1     ContainerCreating   0          14s
admin@ip-172-20-42-121:~$ )kubectl get pods -o wide
-bash: syntax error near unexpected token `)'
admin@ip-172-20-42-121:~$ kubectl get pods -o wide
NAME      READY   STATUS    RESTARTS   AGE   IP           NODE                            NOMINATED NODE
nodeapp   1/1     Running   0          48s   100.96.2.2   ip-172-20-43-186.ec2.internal   
admin@ip-172-20-42-121:~$ kubectl get nodes
NAME                            STATUS   ROLES    AGE     VERSION
ip-172-20-42-121.ec2.internal   Ready    master   9m44s   v1.12.8
ip-172-20-43-186.ec2.internal   Ready    node     8m35s   v1.12.8
ip-172-20-48-165.ec2.internal   Ready    node     8m42s   v1.12.8
admin@ip-172-20-42-121:~$ %%%I AM INTO THE MASTER NOW %%%%%%%^C
admin@ip-172-20-42-121:~$ ifconfig -a
-bash: ifconfig: command not found
admin@ip-172-20-42-121:~$ kubectl describe pod nodeapp
Name:               nodeapp
Namespace:          default
Priority:           0
PriorityClassName: 
Node:               ip-172-20-43-186.ec2.internal/172.20.43.186
Start Time:         Sun, 04 Aug 2019 03:49:51 +0000
Labels:             app=nodeapp
Annotations:        kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container nodeapp
Status:             Running
IP:                 100.96.2.2
Containers:
  nodeapp:
    Container ID:   docker://21de63d6aed84023e75d8a0d0f88759014cac863aada16df748bffb477288528
    Image:          kammana/nodeapp:v1
    Image ID:       docker-pullable://kammana/nodeapp@sha256:2353f9003fb48fb162df6bf8cbd90823c0f0a90e68c87086ae4f1478010a70bb
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sun, 04 Aug 2019 03:50:16 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:        100m
    Environment: 
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-d6jfv (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  default-token-d6jfv:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-d6jfv
    Optional:    false
QoS Class:       Burstable
Node-Selectors: 
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age    From                                    Message
  ----    ------     ----   ----                                    -------
  Normal  Scheduled  3m11s  default-scheduler                       Successfully assigned default/nodeapp to ip-172-20-43-186.ec2.internal
  Normal  Pulling    3m10s  kubelet, ip-172-20-43-186.ec2.internal  pulling image "kammana/nodeapp:v1"
  Normal  Pulled     2m46s  kubelet, ip-172-20-43-186.ec2.internal  Successfully pulled image "kammana/nodeapp:v1"
  Normal  Created    2m46s  kubelet, ip-172-20-43-186.ec2.internal  Created container
  Normal  Started    2m46s  kubelet, ip-172-20-43-186.ec2.internal  Started container
admin@ip-172-20-42-121:~$ curl http://100.96.2.2:8080

Kkrishna- Version 1 - Running on Kubernetes!!!!!


admin@ip-172-20-42-121:~$ kubectl get pods -l 'app=nodeapp'
NAME      READY   STATUS    RESTARTS   AGE
nodeapp   1/1     Running   0          4m13s
admin@ip-172-20-42-121:~$ kubectl create -f https://raw.githubusercontent.com/javahometech/kubernetes/master/services/services.yml
service/my-service created
admin@ip-172-20-42-121:~$ kubectl get services
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   100.64.0.1               443/TCP        14m
my-service   NodePort    100.65.251.221           80:31906/TCP   8s
admin@ip-172-20-42-121:~$

No comments:

Post a Comment