From Fedora Project Wiki

< User:Jasonbrooks

Revision as of 17:20, 28 September 2017 by Jasonbrooks (talk | contribs) (Created page with "{{QA/Test_Case |description=Install Kubernetes on Fedora Atomic Host using system containers and [https://github.com/kubernetes/contrib.git ansi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Install Kubernetes on Fedora Atomic Host using system containers and ansible.

Setup

  • Install one or more Fedora Atomic Hosts.
  • Prepare a host from which to run ansible scripts:
 dnf install ansible python-netaddr git-core -y
  • If you want to run ansible from the atomic host you're testing, use:
 rpm-ostree install ansible python-netaddr git-core && rpm-ostree ex livefs
  • Fetch the ansible scripts:
 git clone https://github.com/kubernetes/contrib.git && cd contrib/ansible  
  • Create an inventory file with your host information.
vi inventory/inventory
# two nodes and one master with host names 
# atomic1, atomic2, atomic3

[masters]
atomic1

[etcd:children]
masters

[nodes]
atomic[2:3]


# all in one setup where you run the ansible
# scripts from the host you're configuring

[masters]
localhost

[etcd:children]
masters

[nodes:children]
masters
  • Enable system containers install option:
vi inventory/group_vars/all.yml
kube_use_node_system_container: true
kube_use_master_system_container: true
kube_use_etcd_system_container: true
kube_use_flannel_system_container: true

  • Configure the authentication section of all.yml as needed:
vi inventory/group_vars/all.yml
# Account name of remote user. Ansible will use this user account to ssh into
# the managed machines. The user must be able to use sudo without asking
# for password unless ansible_sudo_pass is set
#ansible_ssh_user: root

# password for the ansible_ssh_user. If this is unset you will need to set up
# ssh keys so a password is not needed.
#ansible_ssh_pass: password

# If a password is needed to sudo to root that password must be set here
#ansible_sudo_pass: password
 

How to test

Be as specific as required for the target audience.

  • Run the deploy script:
cd scripts
./deploy_cluster.sh
  • ssh to your master host and check on the install:
# kubectl get nodes
NAME        STATUS    AGE       VERSION
localhost   Ready     28m       v1.6.7

# kubectl get pods --all-namespaces
NAMESPACE     NAME                                   READY     STATUS    RESTARTS   AGE
kube-system   elasticsearch-logging-v1-6zg5w         1/1       Running   0          33m
kube-system   elasticsearch-logging-v1-h62pl         1/1       Running   0          33m
kube-system   fluentd-es-v1.20-7r8v5                 1/1       Running   0          28m
kube-system   heapster-v1.2.0-2450593556-10z2c       4/4       Running   0          27m
kube-system   kibana-logging-3308848018-g136s        1/1       Running   0          33m
kube-system   kube-dns-v20-ldj28                     3/3       Running   0          33m
kube-system   monitoring-influxdb-grafana-v3-llxsc   2/2       Running   0          33m

  • Run some test apps
# kubectl run nginx --image=nginx --port=80 --replicas=3
deployment "nginx" created

# kubectl get pods -o wide
NAME                    READY     STATUS    RESTARTS   AGE       IP            NODE
nginx-158599303-dbkjw   1/1       Running   0          19s       172.17.0.3    localhost
nginx-158599303-g4q7c   1/1       Running   0          19s       172.17.0.11   localhost
nginx-158599303-n0mwm   1/1       Running   0          19s       172.17.0.10   localhost

# kubectl expose deployment nginx --type NodePort
service "nginx" exposed

# kubectl get svc
NAME         CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes   10.254.0.1      <none>        443/TCP        40m
nginx        10.254.52.120   <nodes>       80:32681/TCP   14s

# curl http://$HOSTIP:32681
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Expected Results

  1. The ansible scripts run without error.
  2. You're able to run Kubernetes apps using the cluster.