This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1368 from kinvolk/release-v0.6.1
Release v0.6.1
- Loading branch information
Showing
5 changed files
with
222 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
mode="${1}" | ||
|
||
function run_on_host() { | ||
nsenter -a -t 1 /bin/sh -c "${1}" | ||
} | ||
|
||
function update_etcd() { | ||
if [ "${mode}" != "controller" ]; then | ||
echo "Nothing to do. Not a controller node." | ||
return | ||
fi | ||
|
||
rkt_etcd_cfg="/etc/systemd/system/etcd-member.service.d/40-etcd-cluster.conf" | ||
docker_etcd_cfg="/etc/kubernetes/etcd.env" | ||
docker_etcd_svc="/etc/systemd/system/etcd.service" | ||
|
||
if [ -f "${rkt_etcd_cfg}" ]; then | ||
echo "Nothing to do. Rkt based etcd node." | ||
return | ||
fi | ||
|
||
if grep "^IMAGE_TAG" "${docker_etcd_cfg}" >/dev/null; then | ||
echo "etcd env var file ${docker_etcd_cfg} is already updated." | ||
return | ||
fi | ||
|
||
echo -e "\nUpdating etcd file...\nOld etcd config file:\n" | ||
cat "${docker_etcd_cfg}" | ||
sed 's|ETCD_IMAGE_TAG|IMAGE_TAG|g; s|ETCD_IMAGE_URL|IMAGE_URL|g; s|ETCD_SSL_DIR|SSL_DIR|g; s|ETCD_USER|USER|g' ${docker_etcd_cfg} >/tmp/etcd.env | ||
cat /tmp/etcd.env >"${docker_etcd_cfg}" | ||
echo -e "\nNew etcd config file:\n" | ||
cat "${docker_etcd_cfg}" | ||
|
||
echo -e "\nOld etcd service file:\n" | ||
cat "${docker_etcd_svc}" | ||
sed 's|ETCD_IMAGE_TAG|IMAGE_TAG|g; s|ETCD_IMAGE_URL|IMAGE_URL|g; s|ETCD_SSL_DIR|SSL_DIR|g; s|ETCD_USER|USER|g' ${docker_etcd_svc} >/tmp/etcd.service | ||
cat /tmp/etcd.service >"${docker_etcd_svc}" | ||
echo -e "\nNew etcd service file:\n" | ||
cat "${docker_etcd_svc}" | ||
|
||
echo -e "\nRestarting etcd...\n" | ||
run_on_host "systemctl daemon-reload && systemctl is-active etcd && systemctl restart etcd && systemctl status --no-pager etcd" | ||
} | ||
|
||
update_etcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
readonly script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | ||
readonly namespace="update-host-files" | ||
|
||
kubectl create ns "${namespace}" --dry-run=client -o yaml | kubectl apply -f - | ||
kubectl label ns "${namespace}" "lokomotive.kinvolk.io/name=${namespace}" | ||
kubectl create -n "${namespace}" cm script --from-file "${script_dir}"/cluster.sh --dry-run=client -o yaml | kubectl apply -f - | ||
|
||
function update_node_files() { | ||
nodename=$1 | ||
mode=$2 | ||
|
||
podname="uhf-$nodename-$RANDOM" | ||
|
||
echo " | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
run: ${podname} | ||
name: ${podname} | ||
namespace: ${namespace} | ||
spec: | ||
containers: | ||
- image: registry.fedoraproject.org/fedora:32 | ||
name: update-host-files | ||
imagePullPolicy: IfNotPresent | ||
securityContext: | ||
privileged: true | ||
args: | ||
- sh | ||
- -c | ||
- bash /tmp/script/cluster.sh ${mode} | ||
volumeMounts: | ||
- name: etc-kubernetes | ||
mountPath: /etc/kubernetes/ | ||
- name: script | ||
mountPath: /tmp/script/ | ||
- name: rkt-etcd | ||
mountPath: /etc/systemd/system/etcd-member.service.d/ | ||
- name: etcd-service | ||
mountPath: /etc/systemd/system/etcd.service | ||
nodeName: ${nodename} | ||
restartPolicy: Never | ||
hostPID: true | ||
serviceAccountName: default | ||
volumes: | ||
- name: etc-kubernetes | ||
hostPath: | ||
path: /etc/kubernetes/ | ||
- name: etcd-service | ||
hostPath: | ||
path: /etc/systemd/system/etcd.service | ||
- name: script | ||
configMap: | ||
name: script | ||
- name: rkt-etcd | ||
hostPath: | ||
path: /etc/systemd/system/etcd-member.service.d/ | ||
" | kubectl apply -f - | ||
|
||
echo -e "\n\nLogs: ${podname}\n\n" | ||
|
||
# Wait until pod exits. Show logs to the user. | ||
while ! kubectl -n "${namespace}" logs -f "${podname}" 2>/dev/null; do | ||
sleep 1 | ||
done | ||
|
||
echo '-------------------------------------------------------------------------------------------' | ||
} | ||
|
||
function update_controller_nodes() { | ||
for nodename in $(kubectl get nodes -l node.kubernetes.io/master -ojsonpath='{.items[*].metadata.name}'); do | ||
update_node_files "${nodename}" "controller" | ||
done | ||
} | ||
|
||
update_controller_nodes |