-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s_single_node.yaml
85 lines (68 loc) · 2.46 KB
/
k8s_single_node.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
- hosts: k8s-server
tasks:
- name: "Installing vim"
apt: pkg=vim state=installed
- name: "Installing aptitude"
apt: pkg=aptitude state=installed
- name: "Getting docker package key"
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- name: "Getting kubernetes package key"
shell: curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
- name: "Adding docker package repository"
shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- name: "Adding docker repo"
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable
state: present
- name: "Adding kubernetes repo"
apt_repository:
repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
state: present
- name: Update and upgrade apt packages
become: true
apt:
upgrade: safe
update_cache: yes
- name: "Installing docker"
package: name=docker-ce state=present
- name: "Disabling swap"
shell: swapoff -a
tags:
- configure
- name: "Remove current swaps from fstab"
lineinfile:
dest: /etc/fstab
regexp: '^/[\S]+\s+none\s+swap '
state: absent
- name: "Enable docker service"
shell: systemctl enable docker
- name: "Installing transport-https"
apt: pkg=apt-transport-https state=installed
- name: "Installing kubernetes"
apt: name={{item}} state=installed
with_items:
- kubelet
- kubeadm
- kubectl
- selinux-utils
- name: "Reset kubernetes"
shell: kubeadm reset -f
tags:
- reset
- name: "Initializing kubernetes"
shell: kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address $(hostname -i)
tags:
- reset
- name: "Configuring kubectl"
shell: mkdir -p $HOME/.kube;cp /etc/kubernetes/admin.conf $HOME/.kube/config;chown $(id -u):$(id -g) $HOME/.kube/config
tags:
- reset
- name: "Configuring kubernetes network"
shell: kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
tags:
- network
- name: "Configuring single node cluster"
shell: kubectl taint nodes --all node-role.kubernetes.io/master-
tags:
- configure