feat(upgrade-responder): setup dev environment
ref: 5235 Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
This commit is contained in:
parent
33c53e101a
commit
13bf7b6af0
55
dev/upgrade-responder/README.md
Normal file
55
dev/upgrade-responder/README.md
Normal file
@ -0,0 +1,55 @@
|
||||
## Overview
|
||||
|
||||
### Install
|
||||
|
||||
1. Install Longhorn.
|
||||
1. Install Longhorn [upgrade-responder](https://github.com/longhorn/upgrade-responder) stack.
|
||||
```bash
|
||||
./install.sh
|
||||
```
|
||||
Sample output:
|
||||
```shell
|
||||
secret/influxdb-creds created
|
||||
persistentvolumeclaim/influxdb created
|
||||
deployment.apps/influxdb created
|
||||
service/influxdb created
|
||||
Deployment influxdb is running.
|
||||
Cloning into 'upgrade-responder'...
|
||||
remote: Enumerating objects: 1077, done.
|
||||
remote: Counting objects: 100% (1076/1076), done.
|
||||
remote: Compressing objects: 100% (454/454), done.
|
||||
remote: Total 1077 (delta 573), reused 1049 (delta 565), pack-reused 1
|
||||
Receiving objects: 100% (1077/1077), 55.01 MiB | 18.10 MiB/s, done.
|
||||
Resolving deltas: 100% (573/573), done.
|
||||
Release "longhorn-upgrade-responder" does not exist. Installing it now.
|
||||
NAME: longhorn-upgrade-responder
|
||||
LAST DEPLOYED: Thu May 11 00:42:44 2023
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
REVISION: 1
|
||||
TEST SUITE: None
|
||||
NOTES:
|
||||
1. Get the Upgrade Responder server URL by running these commands:
|
||||
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=upgrade-responder,app.kubernetes.io/instance=longhorn-upgrade-responder" -o jsonpath="{.items[0].metadata.name}")
|
||||
kubectl port-forward $POD_NAME 8080:8314 --namespace default
|
||||
echo "Upgrade Responder server URL is http://127.0.0.1:8080"
|
||||
Deployment longhorn-upgrade-responder is running.
|
||||
persistentvolumeclaim/grafana-pvc created
|
||||
deployment.apps/grafana created
|
||||
service/grafana created
|
||||
Deployment grafana is running.
|
||||
|
||||
[Upgrade Checker]
|
||||
URL : http://longhorn-upgrade-responder.default.svc.cluster.local:8314/v1/checkupgrade
|
||||
|
||||
[InfluxDB]
|
||||
URL : http://influxdb.default.svc.cluster.local:8086
|
||||
Database : longhorn_upgrade_responder
|
||||
Username : root
|
||||
Password : root
|
||||
|
||||
[Grafana]
|
||||
Dashboard : http://1.2.3.4:30864
|
||||
Username : admin
|
||||
Password : admin
|
||||
```
|
97
dev/upgrade-responder/install.sh
Executable file
97
dev/upgrade-responder/install.sh
Executable file
@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
|
||||
UPGRADE_RESPONDER_REPO="https://github.com/longhorn/upgrade-responder.git"
|
||||
UPGRADE_RESPONDER_VALUE_YAML="upgrade-responder-value.yaml"
|
||||
UPGRADE_RESPONDER_IMAGE_REPO="longhornio/upgrade-responder"
|
||||
UPGRADE_RESPONDER_IMAGE_TAG="master-head"
|
||||
|
||||
INFLUXDB_URL="http://influxdb.default.svc.cluster.local:8086"
|
||||
|
||||
APP_NAME="longhorn"
|
||||
|
||||
DEPLOYMENT_TIMEOUT_SEC=300
|
||||
DEPLOYMENT_WAIT_INTERVAL_SEC=5
|
||||
|
||||
temp_dir=$(mktemp -d)
|
||||
trap 'rm -r "${temp_dir}"' EXIT
|
||||
|
||||
cp -a ./* ${temp_dir}
|
||||
cd ${temp_dir}
|
||||
|
||||
wait_for_deployment() {
|
||||
local deployment_name="$1"
|
||||
local start_time=$(date +%s)
|
||||
|
||||
while true; do
|
||||
status=$(kubectl rollout status deployment/${deployment_name})
|
||||
if [[ ${status} == *"successfully rolled out"* ]]; then
|
||||
echo "Deployment ${deployment_name} is running."
|
||||
break
|
||||
fi
|
||||
|
||||
elapsed_secs=$(($(date +%s) - ${start_time}))
|
||||
if [[ ${elapsed_secs} -ge ${timeout_secs} ]]; then
|
||||
echo "Timed out waiting for deployment ${deployment_name} to be running."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Deployment ${deployment_name} is not running yet. Waiting..."
|
||||
sleep ${DEPLOYMENT_WAIT_INTERVAL_SEC}
|
||||
done
|
||||
}
|
||||
|
||||
install_influxdb() {
|
||||
kubectl apply -f ./manifests/influxdb.yaml
|
||||
wait_for_deployment "influxdb"
|
||||
}
|
||||
|
||||
install_grafana() {
|
||||
kubectl apply -f ./manifests/grafana.yaml
|
||||
wait_for_deployment "grafana"
|
||||
}
|
||||
|
||||
install_upgrade_responder() {
|
||||
cat << EOF > ${UPGRADE_RESPONDER_VALUE_YAML}
|
||||
applicationName: ${APP_NAME}
|
||||
secret:
|
||||
name: upgrade-responder-secrets
|
||||
managed: true
|
||||
influxDBUrl: "${INFLUXDB_URL}"
|
||||
influxDBUser: "root"
|
||||
influxDBPassword: "root"
|
||||
image:
|
||||
repository: ${UPGRADE_RESPONDER_IMAGE_REPO}
|
||||
tag: ${UPGRADE_RESPONDER_IMAGE_TAG}
|
||||
EOF
|
||||
|
||||
git clone ${UPGRADE_RESPONDER_REPO}
|
||||
helm upgrade --install ${APP_NAME}-upgrade-responder upgrade-responder/chart -f ${UPGRADE_RESPONDER_VALUE_YAML}
|
||||
wait_for_deployment "${APP_NAME}-upgrade-responder"
|
||||
}
|
||||
|
||||
output() {
|
||||
local upgrade_responder_service_info=$(kubectl get svc/${APP_NAME}-upgrade-responder --no-headers)
|
||||
local upgrade_responder_service_port=$(echo "${upgrade_responder_service_info}" | awk '{print $5}' | cut -d'/' -f1)
|
||||
echo # a blank line to separate the installation outputs for better readability.
|
||||
printf "[Upgrade Checker]\n"
|
||||
printf "%-10s: http://${APP_NAME}-upgrade-responder.default.svc.cluster.local:${upgrade_responder_service_port}/v1/checkupgrade\n\n" "URL"
|
||||
|
||||
printf "[InfluxDB]\n"
|
||||
printf "%-10s: ${INFLUXDB_URL}\n" "URL"
|
||||
printf "%-10s: ${APP_NAME}_upgrade_responder\n" "Database"
|
||||
printf "%-10s: root\n" "Username"
|
||||
printf "%-10s: root\n\n" "Password"
|
||||
|
||||
local public_ip=$(curl -s https://ifconfig.me/ip)
|
||||
local grafana_service_info=$(kubectl get svc/grafana --no-headers)
|
||||
local grafana_service_port=$(echo "${grafana_service_info}" | awk '{print $5}' | cut -d':' -f2 | cut -d'/' -f1)
|
||||
printf "[Grafana]\n"
|
||||
printf "%-10s: http://${public_ip}:${grafana_service_port}\n" "Dashboard"
|
||||
printf "%-10s: admin\n" "Username"
|
||||
printf "%-10s: admin\n" "Password"
|
||||
}
|
||||
|
||||
install_influxdb
|
||||
install_upgrade_responder
|
||||
install_grafana
|
||||
output
|
86
dev/upgrade-responder/manifests/grafana.yaml
Normal file
86
dev/upgrade-responder/manifests/grafana.yaml
Normal file
@ -0,0 +1,86 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: grafana-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: longhorn
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: grafana
|
||||
name: grafana
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: grafana
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: grafana
|
||||
spec:
|
||||
securityContext:
|
||||
fsGroup: 472
|
||||
supplementalGroups:
|
||||
- 0
|
||||
containers:
|
||||
- name: grafana
|
||||
image: grafana/grafana:7.1.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: GF_INSTALL_PLUGINS
|
||||
value: "grafana-worldmap-panel"
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
name: http-grafana
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /robots.txt
|
||||
port: 3000
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 30
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 2
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
tcpSocket:
|
||||
port: 3000
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 750Mi
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/grafana
|
||||
name: grafana-pv
|
||||
volumes:
|
||||
- name: grafana-pv
|
||||
persistentVolumeClaim:
|
||||
claimName: grafana-pvc
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: grafana
|
||||
spec:
|
||||
ports:
|
||||
- port: 3000
|
||||
protocol: TCP
|
||||
targetPort: http-grafana
|
||||
selector:
|
||||
app: grafana
|
||||
sessionAffinity: None
|
||||
type: LoadBalancer
|
90
dev/upgrade-responder/manifests/influxdb.yaml
Normal file
90
dev/upgrade-responder/manifests/influxdb.yaml
Normal file
@ -0,0 +1,90 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: influxdb-creds
|
||||
namespace: default
|
||||
type: Opaque
|
||||
data:
|
||||
INFLUXDB_HOST: aW5mbHV4ZGI= # influxdb
|
||||
INFLUXDB_PASSWORD: cm9vdA== # root
|
||||
INFLUXDB_USERNAME: cm9vdA== # root
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: influxdb
|
||||
namespace: default
|
||||
labels:
|
||||
app: influxdb
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: longhorn
|
||||
resources:
|
||||
requests:
|
||||
storage: 2Gi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: influxdb
|
||||
name: influxdb
|
||||
namespace: default
|
||||
spec:
|
||||
progressDeadlineSeconds: 600
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: influxdb
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 25%
|
||||
maxUnavailable: 25%
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: influxdb
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/influxdb:1.8.10
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: influxdb
|
||||
resources: {}
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: influxdb-creds
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/influxdb
|
||||
name: var-lib-influxdb
|
||||
volumes:
|
||||
- name: var-lib-influxdb
|
||||
persistentVolumeClaim:
|
||||
claimName: influxdb
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: influxdb
|
||||
name: influxdb
|
||||
namespace: default
|
||||
spec:
|
||||
ports:
|
||||
- port: 8086
|
||||
protocol: TCP
|
||||
targetPort: 8086
|
||||
selector:
|
||||
app: influxdb
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
Loading…
Reference in New Issue
Block a user