Skip to content

Commit

Permalink
Bump the Kubernetes to v1.10.2 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Bai committed May 14, 2018
1 parent 382a9f9 commit 4e4b87d
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 235 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Build a Kubernetes cluster using Ansible with kubeadm. The goal is easily instal

System requirements:

- Deployment environment must have Ansible `2.4.0`
- Deployment environment must have Ansible `2.4.0+`
- Master and nodes must have passwordless SSH access

# Usage
Expand Down
10 changes: 5 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ Vagrant.configure("2") do |config|

private_count = 10
(1..(master + node)).each do |mid|
name = (mid <= node) ? "node" : "master"
name = (mid <= node) ? "n" : "m"
id = (mid <= node) ? mid : (mid - node)

config.vm.define "#{name}#{id}" do |n|
n.vm.hostname = "#{name}#{id}"
config.vm.define "k8s-#{name}#{id}" do |n|
n.vm.hostname = "k8s-#{name}#{id}"
ip_addr = "192.16.35.#{private_count}"
n.vm.network :private_network, ip: "#{ip_addr}", auto_config: true

n.vm.provider :virtualbox do |vb, override|
vb.name = "kube-#{n.vm.hostname}"
vb.name = "#{n.vm.hostname}"
set_vbox(vb, override)
end
private_count += 1
end
end

# Install of dependency packages using script
config.vm.provision :shell, path: "./scripts/pre-install.sh"
config.vm.provision :shell, path: "./hack/setup-vms.sh"
end
5 changes: 3 additions & 2 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[defaults]
inventory = ./inventory
roles_path = ./roles
inventory = ./hosts.ini

remote_tmp = $HOME/.ansible/tmp
local_tmp = $HOME/.ansible/tmp
pipelining = True
become = True
host_key_checking = False
# callback_whitelist = profile_tasks
deprecation_warnings = False
callback_whitelist = profile_tasks
33 changes: 33 additions & 0 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Kubernetes
kube_version: v1.10.2
token: b0f7b8.8d1767876297d85c

# 1.8.x feature: --feature-gates SelfHosting=true
init_opts: ""

# Any other additional opts you want to add..
kubeadm_opts: ""
# For example:
# kubeadm_opts: '--apiserver-cert-extra-sans "k8s.domain.com,kubernetes.domain.com"'

service_subnet: 10.96.0
service_cidr: "{{ service_subnet }}.0/12"
dns_name: cluster.local
dns_ip: "{{ service_subnet }}.10"

# Network implementation('flannel', 'calico')
network: calico
pod_network_cidr: "10.244.0.0/16"
cni_opts: "interface=eth1" # flannel: --iface=eth1, calico: interface=eth1

enable_dashboard: yes

# A list of insecure registrys you might need to define
insecure_registrys: ""
# insecure_registrys: ['gcr.io']

systemd_dir: /lib/systemd/system
system_env_dir: /etc/sysconfig
network_dir: /etc/kubernetes/network
kubeadmin_config: /etc/kubernetes/admin.conf
kube_addon_dir: /etc/kubernetes/addon
8 changes: 4 additions & 4 deletions scripts/pre-install.sh → hack/setup-vms.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ cat <<EOF > ~/hosts
127.0.0.1 localhost
::1 localhost
192.16.35.10 node1
192.16.35.11 node2
192.16.35.12 master1
192.16.35.10 k8s-n1
192.16.35.11 k8s-n2
192.16.35.12 k8s-m1
EOF
}
Expand All @@ -20,7 +20,7 @@ set -e
HOST_NAME=$(hostname)
OS_NAME=$(awk -F= '/^NAME/{print $2}' /etc/os-release | grep -o "\w*"| head -n 1)

if [ ${HOST_NAME} == "master1" ]; then
if [ ${HOST_NAME} == "k8s-m1" ]; then
case "${OS_NAME}" in
"CentOS")
sudo yum install -y epel-release
Expand Down
9 changes: 9 additions & 0 deletions hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[master]
192.16.35.12

[node]
192.16.35.[10:11]

[kube-cluster:children]
master
node
43 changes: 0 additions & 43 deletions inventory

This file was deleted.

45 changes: 0 additions & 45 deletions roles/addon/tasks/main.yml

This file was deleted.

59 changes: 0 additions & 59 deletions roles/addon/templates/kube-dash-rbac.yml.j2

This file was deleted.

63 changes: 0 additions & 63 deletions roles/addon/templates/kube-dash.yml.j2

This file was deleted.

8 changes: 7 additions & 1 deletion roles/cni/templates/calico.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ spec:
value: "ACCEPT"
# Configure the IP Pool from which Pod IPs will be chosen.
- name: CALICO_IPV4POOL_CIDR
value: "192.168.0.0/16"
value: "{{ pod_network_cidr }}"
- name: CALICO_IPV4POOL_IPIP
value: "always"
# Disable IPv6 on Kubernetes.
Expand All @@ -209,6 +209,12 @@ spec:
# Set Felix logging to "info"
- name: FELIX_LOGSEVERITYSCREEN
value: "info"
{% if cni_opts != '' -%}
- name: IP_AUTODETECTION_METHOD
value: "{{ cni_opts }}"
- name: IP6_AUTODETECTION_METHOD
value: "{{ cni_opts }}"
{% endif -%}
# Auto-detect the BGP IP address.
- name: IP
value: ""
Expand Down
10 changes: 8 additions & 2 deletions roles/cni/templates/flannel.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data:
}
net-conf.json: |
{
"Network": "10.244.0.0/16",
"Network": "{{ pod_network_cidr }}",
"Backend": {
"Type": "vxlan"
}
Expand Down Expand Up @@ -108,7 +108,13 @@ spec:
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.9.1-amd64
command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr" ]
command:
- /opt/bin/flanneld
- --ip-masq
{% if cni_opts != '' -%}
- {{ cni_opts }}
{% endif -%}
- --kube-subnet-mgr
securityContext:
privileged: true
env:
Expand Down
12 changes: 12 additions & 0 deletions roles/kubernetes/master/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Deploy kubernetes dashboard into cluster
when: init_cluster and started_kubelet and enable_dashboard
command: |
kubectl --kubeconfig={{ kubeadmin_config }} \
apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
register: create_result
until: create_result.rc == 0
retries: 5
delay: 2
ignore_errors: true
2 changes: 1 addition & 1 deletion roles/kubernetes/master/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
dependencies:
- { role: commons/os-checker }
- { role: commons/pre-install, pkgs: [ "kubectl", "kubelet", "kubernetes-cni", "kubeadm" ] }
- { role: commons/pre-install, pkgs: ["kubelet", "kubeadm", "kubectl"] }
Loading

0 comments on commit 4e4b87d

Please sign in to comment.