From 3e7924ffda45a1d750700ff1e86019359f90870c Mon Sep 17 00:00:00 2001 From: Spyros Trigazis Date: Wed, 22 Apr 2020 13:49:44 +0300 Subject: [PATCH] Deploy traefik from the heat-agent Use kubectl from the heat agent to apply the traefik deployment. Current behaviour was to create a systemd unit to send the manifests to the API. This way we will have only one way for applying manifests to the API. This change is triggered to adddress the kubectl change [0] that is not using 127.0.0.1:8080 as the default kubernetes API. [0] https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.18.md#kubectl story: 2005286 task: 39522 Change-Id: I8982bd4ec2ab69f35938970d604c16ac5e62e1fa Signed-off-by: Spyros Trigazis --- .../fragments/enable-ingress-traefik.sh | 46 +------------------ ...-from-the-heat-agent-0bb32f0f2c97405d.yaml | 18 ++++++++ 2 files changed, 19 insertions(+), 45 deletions(-) create mode 100644 releasenotes/notes/Deploy-traefik-from-the-heat-agent-0bb32f0f2c97405d.yaml diff --git a/magnum/drivers/common/templates/kubernetes/fragments/enable-ingress-traefik.sh b/magnum/drivers/common/templates/kubernetes/fragments/enable-ingress-traefik.sh index e0ebacc9d0..3f3e717c25 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/enable-ingress-traefik.sh +++ b/magnum/drivers/common/templates/kubernetes/fragments/enable-ingress-traefik.sh @@ -169,54 +169,10 @@ EOF writeFile $INGRESS_TRAEFIK_MANIFEST "$INGRESS_TRAEFIK_MANIFEST_CONTENT" -INGRESS_TRAEFIK_BIN="/srv/magnum/kubernetes/bin/ingress-traefik" -INGRESS_TRAEFIK_SERVICE="/etc/systemd/system/ingress-traefik.service" - -# Binary for ingress traefik -INGRESS_TRAEFIK_BIN_CONTENT='''#!/bin/sh until [ "ok" = "$(curl --silent http://127.0.0.1:8080/healthz)" ] do echo "Waiting for Kubernetes API..." sleep 5 done -# Check if all resources exist already before creating them -kubectl -n kube-system get service ingress-traefik -if [ "$?" != "0" ] && \ - [ -f "'''${INGRESS_TRAEFIK_MANIFEST}'''" ]; then - kubectl create -f '''${INGRESS_TRAEFIK_MANIFEST}''' -fi -''' -writeFile $INGRESS_TRAEFIK_BIN "$INGRESS_TRAEFIK_BIN_CONTENT" - - -# Service for ingress traefik -INGRESS_TRAEFIK_SERVICE_CONTENT='''[Unit] -Requires=kube-apiserver.service - -[Service] -User=root -Group=root -Type=simple -Restart=on-failure -EnvironmentFile=-/etc/kubernetes/config -ExecStart=/bin/bash '''${INGRESS_TRAEFIK_BIN}''' -RestartSec=10 - -[Install] -WantedBy=multi-user.target -''' -writeFile $INGRESS_TRAEFIK_SERVICE "$INGRESS_TRAEFIK_SERVICE_CONTENT" - -chown root:root ${INGRESS_TRAEFIK_BIN} -chmod 0755 ${INGRESS_TRAEFIK_BIN} - -chown root:root ${INGRESS_TRAEFIK_SERVICE} -chmod 0644 ${INGRESS_TRAEFIK_SERVICE} - -# Launch the ingress traefik service -set -x -ssh_cmd="ssh -F /srv/magnum/.ssh/config root@localhost" -$ssh_cmd systemctl daemon-reload -$ssh_cmd systemctl enable ingress-traefik.service -$ssh_cmd systemctl start --no-block ingress-traefik.service +kubectl apply -f ${INGRESS_TRAEFIK_MANIFEST} diff --git a/releasenotes/notes/Deploy-traefik-from-the-heat-agent-0bb32f0f2c97405d.yaml b/releasenotes/notes/Deploy-traefik-from-the-heat-agent-0bb32f0f2c97405d.yaml new file mode 100644 index 0000000000..7d2c91ad2e --- /dev/null +++ b/releasenotes/notes/Deploy-traefik-from-the-heat-agent-0bb32f0f2c97405d.yaml @@ -0,0 +1,18 @@ +--- +fixes: + - | + Deploy traefik from the heat-agent + + Use kubectl from the heat agent to apply the + traefik deployment. Current behaviour was to + create a systemd unit to send the manifests + to the API. + + This way we will have only one way for applying + manifests to the API. + + This change is triggered to adddress the kubectl + change [0] that is not using 127.0.0.1:8080 as + the default kubernetes API. + + [0] https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.18.md#kubectl