Adding keepalived functionality to kolla-kubernetes

This PS adds keepalived pod to kubernetes cluster, keepalived
runs as a daemonset on all compute nodes but it can be controlled by
assigning keepalived label to the kubernetes compute node.

TrivialFix

Change-Id: I01f1f2e6db166ad6b7dadedc62feb22ad9fbf902
This commit is contained in:
Serguei Bezverkhi 2016-09-30 10:03:45 -04:00
parent d1e8d95a91
commit faafb50675
4 changed files with 131 additions and 0 deletions

View File

@ -260,3 +260,4 @@ log_disable:
- iscsi-iscsid
- iscsi-tgtd
- elasticsearch
- keepalived

View File

@ -880,3 +880,24 @@ kolla-kubernetes:
port_name: kibana
image: kibana_image_full
check_path: /
- name: keepalived
pods:
- name: keepalived
containers:
- name: keepalived
- name: keepalived
containers:
- name: keepalived
resources:
configmap:
- name: keepalived
template: services/keepalived/keepalived-configmap.yml.j2
secret:
disk:
pv:
pvc:
svc:
bootstrap:
pod:
- name: keepalived
template: services/keepalived/keepalived-daemonset.yml.j2

View File

@ -0,0 +1,34 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ kolla_kubernetes.cli.args.resource_name }}
namespace: {{ kolla_kubernetes_namespace }}
data:
keepalived.conf: |
vrrp_instance kolla_internal_vip_{{ keepalived_virtual_router_id|default(51) }} {
state MASTER
nopreempt
interface {{ api_interface }}
virtual_router_id {{ keepalived_virtual_router_id|default(51) }}
priority 1
advert_int 1
virtual_ipaddress {
{{ kolla_kubernetes_external_vip }} dev {{ api_interface }}
}
authentication {
auth_type PASS
auth_pass {{ keepalived_password }}
}
}
config.json: |
{
"command": "/usr/sbin/keepalived -nld -p /run/keepalived.pid",
"config_files": [
{
"source": "/var/lib/kolla/config_files/keepalived.conf",
"dest": "/etc/keepalived/keepalived.conf",
"owner": "root",
"perm": "0644"
}
]
}

View File

@ -0,0 +1,75 @@
{%- set resourceName = kolla_kubernetes.cli.args.resource_name %}
{%- set netHostTrue = "yes" %}
{%- import "services/common/common-lib.yml.j2" as lib with context %}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: keepalived
labels:
component: keepalived
system: keepalived
namespace: {{ kolla_kubernetes_namespace }}
spec:
template:
metadata:
labels:
component: keepalived
system: keepalived
annotations:
pod.alpha.kubernetes.io/init-containers: '[
{
"name": "initialize-keepalived-config",
"image": "{{ keepalived_image_full }}",
"command": [
"sh",
"-c",
"cp -a /srv/configmap/..data/* /srv/pod-main-config/;
" ],
"volumeMounts": [
{
"name": "keepalived-configmap",
"mountPath": "/srv/configmap"
},
{
"name": "pod-main-config",
"mountPath": "/srv/pod-main-config"
}
]
}
]'
spec:
hostNetwork: True
nodeSelector:
{%- set selector = kolla_kubernetes_hostlabel_keepalived |
default(kolla_kubernetes_hostlabel_controller) %}
{{ selector.key }}: {{ selector.value }}
containers:
- image: "{{ keepalived_image_full }}"
name: main
securityContext:
privileged: true
env:
- name: KOLLA_CONFIG_STRATEGY
value: {{ config_strategy }}
volumeMounts:
{{ lib.common_volume_mounts(indent=12) }}
- mountPath: {{ container_config_directory }}
name: pod-main-config
readOnly: true
- mountPath: /lib/modules
name: host-lib-modules
- mountPath: /run
name: host-run
volumes:
{{ lib.common_volumes(indent=8) }}
- name: pod-main-config
emptyDir: {}
- name: keepalived-configmap
configMap:
name: keepalived
- name: host-lib-modules
hostPath:
path: /lib/modules
- name: host-run
hostPath:
path: /run