intégration seed mode

This commit is contained in:
Tim 2017-07-04 14:30:45 +02:00
parent 18daf098e7
commit 904a45b7e6
10 changed files with 219 additions and 96 deletions

View file

@ -1,5 +1,5 @@
# Valid bootstrap options (required): ubuntu, coreos, centos, none # Valid bootstrap options (required): ubuntu, coreos, centos, none
bootstrap_os: none bootstrap_os: ubuntu
#Directory where etcd data stored #Directory where etcd data stored
etcd_data_dir: /var/lib/etcd etcd_data_dir: /var/lib/etcd

View file

@ -69,7 +69,14 @@ kube_users:
# Choose network plugin (calico, weave or flannel) # Choose network plugin (calico, weave or flannel)
# Can also be set to 'cloud', which lets the cloud provider setup appropriate routing # Can also be set to 'cloud', which lets the cloud provider setup appropriate routing
kube_network_plugin: calico kube_network_plugin: weave
# weave's network password for encryption
# if null then no network encryption
weave_password: ~t94S:mweJN}32-K
# Set true for use weave's seed mode
mode_seed: false
# Enable kubernetes network policies # Enable kubernetes network policies
enable_network_policy: false enable_network_policy: false

View file

@ -0,0 +1,7 @@
# This file is use to save seed and peers values for weave's seed mode
# This two variable are automatically changed by the weave's role
# For reset values :
# seed: unset
# peers: unset
seed: unset
peers: unset

View file

@ -29,3 +29,7 @@
# [k8s-cluster:children] # [k8s-cluster:children]
# kube-node # kube-node
# kube-master # kube-master
# ## For weave in seed mode
# [k8s-fede:children]
# k8s-cluster

View file

@ -25,7 +25,7 @@ etcd_version: v3.0.17
calico_version: "v1.1.3" calico_version: "v1.1.3"
calico_cni_version: "v1.7.0" calico_cni_version: "v1.7.0"
calico_policy_version: "v0.5.4" calico_policy_version: "v0.5.4"
weave_version: 2.1.1 weave_version: 2.0.1
flannel_version: v0.6.2 flannel_version: v0.6.2
pod_infra_version: 3.0 pod_infra_version: 3.0

View file

@ -4,3 +4,6 @@ weave_memory_limit: 400M
weave_cpu_limit: 30m weave_cpu_limit: 30m
weave_memory_requests: 64M weave_memory_requests: 64M
weave_cpu_requests: 10m weave_cpu_requests: 10m
# this variable is use in seed mode
weave_ip_current_cluster: '{% for host in groups["k8s-cluster"] %}{{ hostvars[host]["ansible_default_ipv4"]["address"] }}{% if not loop.last %} {% endif %}{% endfor %}'

View file

@ -1,6 +1,9 @@
--- ---
- include: pre-upgrade.yml - include: pre-upgrade.yml
- include: seed.yml
when: mode_seed == true
- name: Weave | enable br_netfilter module - name: Weave | enable br_netfilter module
modprobe: modprobe:
name: br_netfilter name: br_netfilter

View file

@ -0,0 +1,49 @@
- name: Weave seed | Set seed first time
set_fact:
weave_seed: '{% for host in groups["k8s-cluster"] %}{{ hostvars[host]["ansible_default_ipv4"]["macaddress"] }}{% if not loop.last %},{% endif %}{% endfor %}'
when: "seed == 'unset'"
run_once: true
tags: confweave
- name: Weave seed | Set seed
set_fact:
weave_seed: '{{ seed }}'
when: "seed != 'unset'"
run_once: true
tags: confweave
- name: Weave seed | Set peers fist time
set_fact:
weave_peers: '{{ weave_ip_current_cluster }}'
when: "peers == 'unset'"
run_once: true
tags: confweave
- name: Weave seed | Set peers with existing peers
set_fact:
weave_peers: '{{ peers }}{% if weave_ip_current_cluster not in peers %} {{ weave_ip_current_cluster }}{% endif %}'
when: "peers != 'unset'"
run_once: true
tags: confweave
- name: Weave seed | Save seed
lineinfile:
dest: "./inventory/group_vars/k8s-fede.yml"
state: present
regexp: '^seed:'
line: 'seed: {{ weave_seed }}'
become_user: $USER
delegate_to: 127.0.0.1
run_once: true
tags: confweave
- name: Weave seed | Save peers
lineinfile:
dest: "./inventory/group_vars/k8s-fede.yml"
state: present
regexp: '^peers:'
line: 'peers: {{ weave_peers }}'
become_user: $USER
delegate_to: 127.0.0.1
run_once: true
tags: confweave

View file

@ -1,82 +1,117 @@
--- ---
apiVersion: extensions/v1beta1 apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: ServiceAccount
metadata:
name: weave-net
labels:
name: weave-net
namespace: {{ system_namespace }}
- apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: weave-net
labels:
name: weave-net
rules:
- apiGroups:
- ''
resources:
- pods
- namespaces
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- networkpolicies
verbs:
- get
- list
- watch
- apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: weave-net
labels:
name: weave-net
roleRef:
kind: ClusterRole
name: weave-net
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: weave-net
namespace: kube-system
- apiVersion: extensions/v1beta1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
name: weave-net name: weave-net
namespace: {{ system_namespace }}
labels: labels:
name: weave-net
version: {{ weave_version }} version: {{ weave_version }}
namespace: {{ system_namespace }}
spec: spec:
template: template:
metadata: metadata:
labels: labels:
name: weave-net name: weave-net
annotations:
scheduler.alpha.kubernetes.io/tolerations: |
[
{
"key": "dedicated",
"operator": "Equal",
"value": "master",
"effect": "NoSchedule"
}
]
spec: spec:
hostNetwork: true
hostPID: true
containers: containers:
- name: weave - name: weave
image: {{ weave_kube_image_repo }}:{{ weave_kube_image_tag }} {% if mode_seed == true %}
imagePullPolicy: Always command: ["/bin/sh","-c","export EXTRA_ARGS=--name=$(cat /sys/class/net/{{ ansible_default_ipv4['interface'] }}/address) && /home/weave/launch.sh"]
{% else %}
command: command:
- /home/weave/launch.sh - /home/weave/launch.sh
{% endif %}
env: env:
- name: HOSTNAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: IPALLOC_RANGE - name: IPALLOC_RANGE
value: {{ kube_pods_subnet }} value: {{ kube_pods_subnet }}
{% if weave_checkpoint_disable is defined %} {% if mode_seed == true %}
- name: CHECKPOINT_DISABLE
value: {{ weave_checkpoint_disable }}
{% endif %}
{% if weave_expect_npc is defined %}
- name: EXPECT_NPC
value: {{ weave_expect_npc }}
{% endif %}
{% if weave_kube_peers is defined %}
- name: KUBE_PEERS - name: KUBE_PEERS
value: {{ weave_kube_peers }} value: {{ weave_peers }}
{% endif %}
{% if weave_ipalloc_init is defined %}
- name: IPALLOC_INIT - name: IPALLOC_INIT
value: {{ weave_ipalloc_init }} value: seed={{ weave_seed }}
{% endif %}
{% if weave_expose_ip is defined %}
- name: WEAVE_EXPOSE_IP
value: {{ weave_expose_ip }}
{% endif %} {% endif %}
- name: WEAVE_PASSWORD
value: {{ weave_password }}
image: {{ weave_kube_image_repo }}:{{ weave_kube_image_tag }}
imagePullPolicy: Always
livenessProbe: livenessProbe:
initialDelaySeconds: 60
httpGet: httpGet:
host: 127.0.0.1 host: 127.0.0.1
path: /status path: /status
port: 6784 port: 6784
initialDelaySeconds: 30
resources:
requests:
cpu: 10m
securityContext: securityContext:
privileged: true privileged: true
volumeMounts: volumeMounts:
- name: weavedb - name: weavedb
mountPath: /weavedb mountPath: /weavedb
- name: cni-bin - name: cni-bin
mountPath: /opt mountPath: /host/opt
- name: cni-bin2 - name: cni-bin2
mountPath: /host_home mountPath: /host/home
- name: cni-conf - name: cni-conf
mountPath: /etc mountPath: /host/etc
resources: - name: dbus
requests: mountPath: /host/var/lib/dbus
cpu: {{ weave_cpu_requests }} - name: lib-modules
memory: {{ weave_memory_requests }} mountPath: /lib/modules
limits:
cpu: {{ weave_cpu_limit }}
memory: {{ weave_memory_limit }}
- name: weave-npc - name: weave-npc
image: {{ weave_npc_image_repo }}:{{ weave_npc_image_tag }} image: {{ weave_npc_image_repo }}:{{ weave_npc_image_tag }}
imagePullPolicy: Always imagePullPolicy: Always
@ -89,10 +124,19 @@ spec:
memory: {{ weave_memory_limit }} memory: {{ weave_memory_limit }}
securityContext: securityContext:
privileged: true privileged: true
hostNetwork: true
hostPID: true
restartPolicy: Always restartPolicy: Always
securityContext:
seLinuxOptions: {}
serviceAccountName: weave-net
tolerations:
- effect: NoSchedule
operator: Exists
volumes: volumes:
- name: weavedb - name: weavedb
emptyDir: {} hostPath:
path: /var/lib/weave
- name: cni-bin - name: cni-bin
hostPath: hostPath:
path: /opt path: /opt
@ -102,3 +146,9 @@ spec:
- name: cni-conf - name: cni-conf
hostPath: hostPath:
path: /etc path: /etc
- name: dbus
hostPath:
path: /var/lib/dbus
- name: lib-modules
hostPath:
path: /lib/modules

View file

@ -5,7 +5,7 @@ local_release_dir: /tmp
etcd_version: v3.0.17 etcd_version: v3.0.17
calico_version: v0.23.0 calico_version: v0.23.0
calico_cni_version: v1.5.6 calico_cni_version: v1.5.6
weave_version: v2.1.1 weave_version: v2.0.1
# Download URL's # Download URL's
etcd_download_url: "https://github.com/coreos/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-amd64.tar.gz" etcd_download_url: "https://github.com/coreos/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-amd64.tar.gz"