Move Kubernetes proxy to the container

Move Kubernetes proxy to the container

Change-Id: Ia3503ba6087f6a18ffea5d9387388a6c42a16f86
Partially-Implements: blueprint run-kube-as-container
This commit is contained in:
Egor Guz 2015-11-28 14:25:11 -08:00
parent 1dd52e3287
commit 0753fb921e
7 changed files with 115 additions and 4 deletions

View File

@ -20,12 +20,12 @@ sed -i '
/^KUBE_MASTER=/ s|=.*|="--master='"$KUBE_MASTER_URI"'"|
' /etc/kubernetes/config
KUBELET_ARGS="--cadvisor-port=4194 $KUBE_CONFIG"
KUBELET_ARGS="--config=/etc/kubernetes/manifests --cadvisor-port=4194 ${KUBE_CONFIG}"
sed -i '
/^KUBELET_ADDRESS=/ s/=.*/="--address=0.0.0.0"/
/^KUBELET_HOSTNAME=/ s/=.*/=""/
/^KUBELET_API_SERVER=/ s|=.*|="--api_servers='"$KUBE_MASTER_URI"'"|
/^KUBELET_ARGS=/ s|=.*|='"$KUBELET_ARGS"'|
/^KUBELET_ARGS=/ s|=.*|='"${KUBELET_ARGS}"'|
' /etc/kubernetes/kubelet
sed -i '

View File

@ -0,0 +1,41 @@
#!/bin/sh
. /etc/sysconfig/heat-params
function init_templates {
local TEMPLATE=/etc/kubernetes/manifests/kube-proxy.yaml
[ -f ${TEMPLATE} ] || {
echo "TEMPLATE: $TEMPLATE"
mkdir -p $(dirname ${TEMPLATE})
cat << EOF > ${TEMPLATE}
apiVersion: v1
kind: Pod
metadata:
name: kube-proxy
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-proxy
image: gcr.io/google_containers/hyperkube:v1.0.6
command:
- /hyperkube
- proxy
- --master=http://127.0.0.1:8080
- --logtostderr=true
- --v=0
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/ssl/certs
name: ssl-certs-host
readOnly: true
volumes:
- hostPath:
path: /etc/ssl/certs
name: ssl-certs-host
EOF
}
}
init_templates

View File

@ -0,0 +1,56 @@
#!/bin/sh
. /etc/sysconfig/heat-params
function init_templates {
local KUBE_PROTOCOL="https"
local KUBE_CONFIG="/srv/kubernetes/kubeconfig.yaml"
if [ "${TLS_DISABLED}" == "True" ]; then
KUBE_PROTOCOL="http"
KUBE_CONFIG=
fi
local MASTER="${KUBE_PROTOCOL}://${KUBE_MASTER_IP}:${KUBE_API_PORT}"
local TEMPLATE=/etc/kubernetes/manifests/kube-proxy.yaml
[ -f ${TEMPLATE} ] || {
echo "TEMPLATE: $TEMPLATE"
mkdir -p $(dirname ${TEMPLATE})
cat << EOF > ${TEMPLATE}
apiVersion: v1
kind: Pod
metadata:
name: kube-proxy
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-proxy
image: gcr.io/google_containers/hyperkube:v1.0.6
command:
- /hyperkube
- proxy
- --master=${MASTER}
- --kubeconfig=${KUBE_CONFIG}
- --logtostderr=true
- --v=0
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/ssl/certs
name: ssl-certs-host
readOnly: true
- mountPath: /srv/kubernetes
name: "srv-kube"
readOnly: true
volumes:
- hostPath:
path: /etc/ssl/certs
name: ssl-certs-host
- hostPath:
path: "/srv/kubernetes"
name: "srv-kube"
EOF
}
}
init_templates

View File

@ -4,7 +4,7 @@
systemctl daemon-reload
echo "starting services"
for service in etcd docker kube-apiserver kube-proxy kubelet; do
for service in etcd docker kube-apiserver kubelet; do
echo "activating service $service"
systemctl enable $service
systemctl --no-block start $service

View File

@ -10,7 +10,7 @@ ip link del docker0
# make sure we pick up any modified unit files
systemctl daemon-reload
for service in docker kubelet kube-proxy; do
for service in docker kubelet; do
echo "activating service $service"
systemctl enable $service
systemctl --no-block start $service

View File

@ -275,6 +275,12 @@ resources:
group: ungrouped
config: {get_file: fragments/kube-ui-service.sh}
enable_kube_proxy:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/enable-kube-proxy-master.sh}
master_wc_notify:
type: OS::Heat::SoftwareConfig
properties:
@ -317,6 +323,7 @@ resources:
- config: {get_resource: network_service}
- config: {get_resource: kube_system_namespace_service}
- config: {get_resource: enable_kube_podmaster}
- config: {get_resource: enable_kube_proxy}
- config: {get_resource: kube_ui_service}
- config: {get_resource: kube_examples}
- config: {get_resource: master_wc_notify}

View File

@ -277,6 +277,12 @@ resources:
group: ungrouped
config: {get_file: fragments/enable-docker-registry.sh}
enable_kube_proxy:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/enable-kube-proxy-minion.sh}
minion_wc_notify:
type: OS::Heat::SoftwareConfig
properties:
@ -317,6 +323,7 @@ resources:
- config: {get_resource: network_service}
- config: {get_resource: add_proxy}
- config: {get_resource: enable_services}
- config: {get_resource: enable_kube_proxy}
- config: {get_resource: enable_docker_registry}
- config: {get_resource: minion_wc_notify}