Container Infrastructure Management Service for OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0KB

  1. #!/bin/bash
  2. set -ex
  3. CHART_NAME="metrics-server"
  4. CHART_VERSION="2.1.0"
  5. HELM_MODULE_CONFIG_FILE="/srv/magnum/kubernetes/helm/${CHART_NAME}.yaml"
  6. [ -f ${HELM_MODULE_CONFIG_FILE} ] || {
  7. echo "Writing File: ${HELM_MODULE_CONFIG_FILE}"
  8. mkdir -p $(dirname ${HELM_MODULE_CONFIG_FILE})
  9. cat << EOF > ${HELM_MODULE_CONFIG_FILE}
  10. ---
  11. kind: ConfigMap
  12. apiVersion: v1
  13. metadata:
  14. name: ${CHART_NAME}-config
  15. namespace: magnum-tiller
  16. labels:
  17. app: helm
  18. data:
  19. install-${CHART_NAME}.sh: |
  20. #!/bin/bash
  21. set -e
  22. set -x
  23. mkdir -p \${HELM_HOME}
  24. cp /etc/helm/* \${HELM_HOME}
  25. # HACK - Force wait because of bug https://github.com/helm/helm/issues/5170
  26. until helm init --client-only --wait
  27. do
  28. sleep 5s
  29. done
  30. helm repo update
  31. if [[ \$(helm history metrics-server | grep metrics-server) ]]; then
  32. echo "${CHART_NAME} already installed on server. Continue..."
  33. exit 0
  34. else
  35. helm install stable/${CHART_NAME} --namespace kube-system --name ${CHART_NAME} --version v${CHART_VERSION}
  36. fi
  37. ---
  38. apiVersion: batch/v1
  39. kind: Job
  40. metadata:
  41. name: install-${CHART_NAME}-job
  42. namespace: magnum-tiller
  43. spec:
  44. backoffLimit: 5
  45. template:
  46. spec:
  47. serviceAccountName: tiller
  48. containers:
  49. - name: config-helm
  50. image: ${CONTAINER_INFRA_PREFIX:-docker.io/openstackmagnum/}helm-client:dev
  51. command:
  52. - bash
  53. args:
  54. - /opt/magnum/install-${CHART_NAME}.sh
  55. env:
  56. - name: HELM_HOME
  57. value: /helm_home
  58. - name: TILLER_NAMESPACE
  59. value: magnum-tiller
  60. - name: HELM_TLS_ENABLE
  61. value: "true"
  62. volumeMounts:
  63. - name: install-${CHART_NAME}-config
  64. mountPath: /opt/magnum/
  65. - mountPath: /etc/helm
  66. name: helm-client-certs
  67. restartPolicy: Never
  68. volumes:
  69. - name: install-${CHART_NAME}-config
  70. configMap:
  71. name: ${CHART_NAME}-config
  72. - name: helm-client-certs
  73. secret:
  74. secretName: helm-client-secret
  75. EOF
  76. }