Update fedora_ansible_config.md
This commit is contained in:
		
							parent
							
								
									51fcf507da
								
							
						
					
					
						commit
						e38623ac4c
					
				| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Configuring Kubernetes on Fedora via Ansible offers a simple way to quickly create a clustered environment with little effort.
 | 
					Configuring Kubernetes on Fedora via Ansible offers a simple way to quickly create a clustered environment with little effort.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* TOC
 | 
					* TOC
 | 
				
			||||||
{:toc}
 | 
					{:toc}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Prerequisites
 | 
					## Prerequisites
 | 
				
			||||||
| 
						 | 
					@ -18,12 +18,12 @@ The hosts can be virtual or bare metal. Ansible will take care of the rest of th
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A Kubernetes cluster requires etcd, a master, and n nodes, so we will create a cluster with three hosts, for example:
 | 
					A Kubernetes cluster requires etcd, a master, and n nodes, so we will create a cluster with three hosts, for example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
master,etcd = kube-master.example.com
 | 
					master,etcd = kube-master.example.com
 | 
				
			||||||
    node1 = kube-node-01.example.com
 | 
					    node1 = kube-node-01.example.com
 | 
				
			||||||
    node2 = kube-node-02.example.com
 | 
					    node2 = kube-node-02.example.com
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Make sure your local machine has**
 | 
					**Make sure your local machine has**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 - ansible (must be 1.9.0+)
 | 
					 - ansible (must be 1.9.0+)
 | 
				
			||||||
| 
						 | 
					@ -32,22 +32,22 @@ master,etcd = kube-master.example.com
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If not
 | 
					If not
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
yum install -y ansible git python-netaddr
 | 
					yum install -y ansible git python-netaddr
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Now clone down the Kubernetes repository**
 | 
					**Now clone down the Kubernetes repository**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
git clone https://github.com/kubernetes/contrib.git
 | 
					git clone https://github.com/kubernetes/contrib.git
 | 
				
			||||||
cd contrib/ansible
 | 
					cd contrib/ansible
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Tell ansible about each machine and its role in your cluster**
 | 
					**Tell ansible about each machine and its role in your cluster**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Get the IP addresses from the master and nodes.  Add those to the `~/contrib/ansible/inventory` file on the host running Ansible.
 | 
					Get the IP addresses from the master and nodes.  Add those to the `~/contrib/ansible/inventory` file on the host running Ansible.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
[masters]
 | 
					[masters]
 | 
				
			||||||
kube-master.example.com
 | 
					kube-master.example.com
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,8 +57,8 @@ kube-master.example.com
 | 
				
			||||||
[nodes]
 | 
					[nodes]
 | 
				
			||||||
kube-node-01.example.com
 | 
					kube-node-01.example.com
 | 
				
			||||||
kube-node-02.example.com
 | 
					kube-node-02.example.com
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Setting up ansible access to your nodes
 | 
					## Setting up ansible access to your nodes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you already are running on a machine which has passwordless ssh access to the kube-master and kube-node-{01,02} nodes, and 'sudo' privileges, simply set the value of `ansible_ssh_user` in `~/contrib/ansible/group_vars/all.yml` to the username which you use to ssh to the nodes (i.e. `fedora`), and proceed to the next step...
 | 
					If you already are running on a machine which has passwordless ssh access to the kube-master and kube-node-{01,02} nodes, and 'sudo' privileges, simply set the value of `ansible_ssh_user` in `~/contrib/ansible/group_vars/all.yml` to the username which you use to ssh to the nodes (i.e. `fedora`), and proceed to the next step...
 | 
				
			||||||
| 
						 | 
					@ -67,52 +67,52 @@ If you already are running on a machine which has passwordless ssh access to the
 | 
				
			||||||
 | 
					
 | 
				
			||||||
edit: ~/contrib/ansible/group_vars/all.yml
 | 
					edit: ~/contrib/ansible/group_vars/all.yml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
ansible_ssh_user: root
 | 
					ansible_ssh_user: root
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Configuring ssh access to the cluster**
 | 
					**Configuring ssh access to the cluster**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you already have ssh access to every machine using ssh public keys you may skip to [setting up the cluster](#setting-up-the-cluster)
 | 
					If you already have ssh access to every machine using ssh public keys you may skip to [setting up the cluster](#setting-up-the-cluster)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Make sure your local machine (root) has an ssh key pair if not
 | 
					Make sure your local machine (root) has an ssh key pair if not
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
ssh-keygen
 | 
					ssh-keygen
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Copy the ssh public key to **all** nodes in the cluster
 | 
					Copy the ssh public key to **all** nodes in the cluster
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
for node in kube-master.example.com kube-node-01.example.com kube-node-02.example.com; do
 | 
					for node in kube-master.example.com kube-node-01.example.com kube-node-02.example.com; do
 | 
				
			||||||
  ssh-copy-id ${node}
 | 
					  ssh-copy-id ${node}
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Setting up the cluster
 | 
					## Setting up the cluster
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Although the default value of variables in `~/contrib/ansible/group_vars/all.yml` should be good enough, if not, change them as needed.
 | 
					Although the default value of variables in `~/contrib/ansible/group_vars/all.yml` should be good enough, if not, change them as needed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```conf
 | 
					```conf
 | 
				
			||||||
edit: ~/contrib/ansible/group_vars/all.yml
 | 
					edit: ~/contrib/ansible/group_vars/all.yml
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Configure access to kubernetes packages**
 | 
					**Configure access to kubernetes packages**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Modify `source_type` as below to access kubernetes packages through the package manager.
 | 
					Modify `source_type` as below to access kubernetes packages through the package manager.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
source_type: packageManager
 | 
					source_type: packageManager
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Configure the IP addresses used for services**
 | 
					**Configure the IP addresses used for services**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Each Kubernetes service gets its own IP address.  These are not real IPs.  You need only select a range of IPs which are not in use elsewhere in your environment.
 | 
					Each Kubernetes service gets its own IP address.  These are not real IPs.  You need only select a range of IPs which are not in use elsewhere in your environment.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
kube_service_addresses: 10.254.0.0/16
 | 
					kube_service_addresses: 10.254.0.0/16
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Managing flannel**
 | 
					**Managing flannel**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Modify `flannel_subnet`, `flannel_prefix` and `flannel_host_prefix` only if defaults are not appropriate for your cluster.
 | 
					Modify `flannel_subnet`, `flannel_prefix` and `flannel_host_prefix` only if defaults are not appropriate for your cluster.
 | 
				
			||||||
| 
						 | 
					@ -122,32 +122,32 @@ Modify `flannel_subnet`, `flannel_prefix` and `flannel_host_prefix` only if defa
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Set `cluster_logging` to false or true (default) to disable or enable logging with elasticsearch.
 | 
					Set `cluster_logging` to false or true (default) to disable or enable logging with elasticsearch.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
cluster_logging: true
 | 
					cluster_logging: true
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Turn `cluster_monitoring` to true (default) or false to enable or disable cluster monitoring with heapster and influxdb.
 | 
					Turn `cluster_monitoring` to true (default) or false to enable or disable cluster monitoring with heapster and influxdb.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
cluster_monitoring: true
 | 
					cluster_monitoring: true
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Turn `dns_setup` to true (recommended) or false to enable or disable whole DNS configuration.
 | 
					Turn `dns_setup` to true (recommended) or false to enable or disable whole DNS configuration.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
dns_setup: true
 | 
					dns_setup: true
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Tell ansible to get to work!**
 | 
					**Tell ansible to get to work!**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This will finally setup your whole Kubernetes cluster for you.
 | 
					This will finally setup your whole Kubernetes cluster for you.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
cd ~/contrib/ansible/
 | 
					cd ~/contrib/ansible/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
./setup.sh
 | 
					./setup.sh
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Testing and using your new cluster
 | 
					## Testing and using your new cluster
 | 
				
			||||||
 | 
					
 | 
				
			||||||
That's all there is to it.  It's really that easy.  At this point you should have a functioning Kubernetes cluster.
 | 
					That's all there is to it.  It's really that easy.  At this point you should have a functioning Kubernetes cluster.
 | 
				
			||||||
| 
						 | 
					@ -156,25 +156,26 @@ That's all there is to it.  It's really that easy.  At this point you should hav
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Run the following on the kube-master:
 | 
					Run the following on the kube-master:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
kubectl get nodes
 | 
					kubectl get nodes
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Show services running on masters and nodes**
 | 
					**Show services running on masters and nodes**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
systemctl | grep -i kube
 | 
					systemctl | grep -i kube
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Show firewall rules on the masters and nodes**
 | 
					**Show firewall rules on the masters and nodes**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
iptables -nvL
 | 
					iptables -nvL
 | 
				
			||||||
```
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Create /tmp/apache.json on the master with the following contents and deploy pod**
 | 
					**Create /tmp/apache.json on the master with the following contents and deploy pod**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```json
 | 
					```json
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "kind": "Pod",
 | 
					  "kind": "Pod",
 | 
				
			||||||
  "apiVersion": "v1",
 | 
					  "apiVersion": "v1",
 | 
				
			||||||
| 
						 | 
					@ -199,29 +200,38 @@ iptables -nvL
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
kubectl create -f /tmp/apache.json
 | 
					kubectl create -f /tmp/apache.json
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Check where the pod was created**
 | 
					**Check where the pod was created**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
kubectl get pods
 | 
					kubectl get pods
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Check Docker status on nodes**
 | 
					**Check Docker status on nodes**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
docker ps
 | 
					docker ps
 | 
				
			||||||
docker images
 | 
					docker images
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**After the pod is 'Running' Check web server access on the node**
 | 
					**After the pod is 'Running' Check web server access on the node**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
curl http://localhost
 | 
					curl http://localhost
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
That's it !
 | 
					That's it !
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Support Level
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IaaS Provider        | Config. Mgmt | OS     | Networking  | Docs                                              | Conforms | Support Level
 | 
				
			||||||
 | 
					-------------------- | ------------ | ------ | ----------  | ---------------------------------------------     | ---------| ----------------------------
 | 
				
			||||||
 | 
					Bare-metal           | Ansible      | Fedora | flannel     | [docs](/docs/getting-started-guides/fedora/fedora_ansible_config)           |          | Project
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					For support level information on all solutions, see the [Table of solutions](/docs/getting-started-guides/#table-of-solutions) chart.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue