diff --git a/charts/ocean-network-client/Chart.yaml b/charts/ocean-network-client/Chart.yaml index e04898f..9434964 100644 --- a/charts/ocean-network-client/Chart.yaml +++ b/charts/ocean-network-client/Chart.yaml @@ -17,7 +17,7 @@ maintainers: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.0.23 +version: 1.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/ocean-network-client/README.md b/charts/ocean-network-client/README.md index 93ab927..39483e8 100644 --- a/charts/ocean-network-client/README.md +++ b/charts/ocean-network-client/README.md @@ -1,6 +1,6 @@ # ocean-network-client -![Version: 1.0.23](https://img.shields.io/badge/Version-1.0.23-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.8](https://img.shields.io/badge/AppVersion-1.0.8-informational?style=flat-square) +![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.8](https://img.shields.io/badge/AppVersion-1.0.8-informational?style=flat-square) A Helm chart for Ocean Network Client. @@ -18,10 +18,21 @@ helm repo add spot https://charts.spot.io helm repo update ``` -3. Install `ocean-network-client`: +3a. Install `ocean-network-client` and generate secret and configMap: +```sh +helm install my-release spot/ocean-network-client \ + --set spotinst.account=$SPOTINST_ACCOUNT \ + --set spotinst.clusterIdentifier=$SPOTINST_CLUSTER_IDENTIFIER \ + --set spotinst.token=$SPOTINST_TOKEN \ + --namespace spot-system --set namespace=spot-system +``` +3b. Install `ocean-network-client` with your own secret or configMap: ```sh -helm install my-release spot/ocean-network-client +helm install my-release spot/ocean-network-client \ + --set secretName=$SECRET_NAME \ + --set configMapName=$CONFIG_MAP_NAME \ + --namespace spot-system --set namespace=spot-system ``` > NOTE: Please configure all required chart values using the `set` command line argument or a `values.yaml` file. @@ -30,15 +41,19 @@ helm install my-release spot/ocean-network-client | Key | Type | Default | Description | |-----|------|---------|-------------| -| configMapName | Optional | `"spotinst-kubernetes-cluster-controller-config"` | ConfigMap name. | +| configMapName | Optional | `""` | ConfigMap name. | +| fullnameOverride | string | `""` | | | image.pullPolicy | Optional | `"IfNotPresent"` | Image pull policy. | | image.pullSecrets | Optional | `[]` | Image pull secrets. | | image.repository | Optional | `"public.ecr.aws/spotinst/spot-network-client"` | Image repository. | | image.tag | Optional | `""` | Image tag. Defaults to `.Chart.AppVersion`. | -| namespace | Optional | `"kube-system"` | Namespace where components should be installed. | -| oceanInfoData | Optional | `"spotinst-ocean-cluster"` | ConfigMap name. | +| nameOverride | string | `""` | | +| namespace | Optional | `"kube-system"` | namespace override. | +| oceanController | object | `{"configMapName":"","secretName":""}` | Reference secret and configMap for the Ocean Controller. Deprecated in favor of secret and configMap objects | +| oceanController.configMapName | Optional | `""` | ConfigMap name. Deprecated use configMapName instead | +| oceanController.secretName | Optional | `""` | Secret name. Deprecated use secretName instead. | | resources | Optional | `{"requests":{"cpu":"30m","memory":"150Mi"}}` | Resource requests and limits. Ref: http://kubernetes.io/docs/user-guide/compute-resources/ | -| secretName | Optional | `"spotinst-kubernetes-cluster-controller"` | Secret name. | +| secretName | Optional | `""` | Secret name. | | spotinst.account | Optional | `""` | Spot Account. Ref: https://docs.spot.io/administration/organizations?id=account | | spotinst.clusterIdentifier | Optional | `""` | Unique identifier used by the Ocean Controller to connect between the Ocean backend and the Kubernetes cluster. Ref: https://docs.spot.io/ocean/tutorials/spot-kubernetes-controller/ | | spotinst.token | Optional | `""` | Spot Token. Ref: https://docs.spot.io/administration/api/create-api-token | diff --git a/charts/ocean-network-client/README.md.gotmpl b/charts/ocean-network-client/README.md.gotmpl index cf7d1ae..afa98aa 100644 --- a/charts/ocean-network-client/README.md.gotmpl +++ b/charts/ocean-network-client/README.md.gotmpl @@ -20,10 +20,21 @@ helm repo add spot https://charts.spot.io helm repo update ``` -3. Install `{{ template "chart.name" . }}`: +3a. Install `{{ template "chart.name" . }}` and generate secret and configMap: +```sh +helm install my-release spot/{{ template "chart.name" . }} \ + --set spotinst.account=$SPOTINST_ACCOUNT \ + --set spotinst.clusterIdentifier=$SPOTINST_CLUSTER_IDENTIFIER \ + --set spotinst.token=$SPOTINST_TOKEN \ + --namespace spot-system --set namespace=spot-system +``` +3b. Install `{{ template "chart.name" . }}` with your own secret or configMap: ```sh -helm install my-release spot/{{ template "chart.name" . }} +helm install my-release spot/{{ template "chart.name" . }} \ + --set secretName=$SECRET_NAME \ + --set configMapName=$CONFIG_MAP_NAME \ + --namespace spot-system --set namespace=spot-system ``` > NOTE: Please configure all required chart values using the `set` command line argument or a `values.yaml` file. diff --git a/charts/ocean-network-client/templates/NOTES.txt b/charts/ocean-network-client/templates/NOTES.txt index e0b1f16..ffee8c9 100644 --- a/charts/ocean-network-client/templates/NOTES.txt +++ b/charts/ocean-network-client/templates/NOTES.txt @@ -2,6 +2,6 @@ Thank you for installing {{ .Release.Name }}. Please make sure that each node in your cluster has the Network-Client DaemonSet running: - $ kubectl get daemonset {{ .Release.Name }} -n {{ .Values.namespace }} + $ kubectl get daemonset {{ .Release.Name }} -n {{ include "ocean-network-client.namespace" . }} The collection of the data has already begun, you can see the data in our UI console or via API in 2-3 hours. diff --git a/charts/ocean-network-client/templates/_helpers.tpl b/charts/ocean-network-client/templates/_helpers.tpl index 234e2df..a5d9be3 100644 --- a/charts/ocean-network-client/templates/_helpers.tpl +++ b/charts/ocean-network-client/templates/_helpers.tpl @@ -2,24 +2,69 @@ Expand the name of the chart. */}} {{- define "ocean-network-client.name" -}} -{{- default .Chart.Name .Values.name | trunc 63 | trimSuffix "-" }} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Namespace. */}} {{- define "ocean-network-client.namespace" -}} -{{ default (include "ocean-network-client.name" .) .Values.namespace }} +{{ default .Release.Namespace .Values.namespace }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "ocean-network-client.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} {{- end }} {{/* ConfigMap name. */}} {{- define "ocean-network-client.configMapName" -}} -{{- if ne .Values.spotinst.clusterIdentifier "" -}} -{{- .Values.oceanInfoData -}} +{{- if include "ocean-network-client.createConfigMap" . -}} + +{{/* +Validate oceanController.configMapName was not provided in case we need to create configMap. +*/}} +{{- if .Values.oceanController.configMapName -}} +{{- fail "`oceanController.configMapName` cannot be provided in case `spotinst.controllerClusterId` was provided. Please use `configMapName` instead" }} +{{- end -}} + +{{- default (include "ocean-network-client.fullname" .) .Values.configMapName -}} {{- else -}} -{{- default (include "ocean-network-client.name" .) .Values.configMapName -}} + +{{/* +Validate both oceanController.configMapName and configMapName were not provided together with different values +*/}} +{{- if and .Values.oceanController.configMapName .Values.configMapName -}} +{{- if ne .Values.oceanController.configMapName .Values.configMapName -}} +{{- fail "Both `oceanController.configMapName` and `configMapName` were provided with different values. Please use `configMapName`" }} +{{- end -}} +{{- end -}} + +{{- default "spotinst-kubernetes-cluster-controller-config" (default .Values.oceanController.configMapName .Values.configMapName) -}} +{{- end -}} +{{- end -}} + +{{/* +create ConfigMap. +*/}} +{{- define "ocean-network-client.createConfigMap" -}} +{{- if .Values.spotinst.clusterIdentifier -}} +{{- true -}} {{- end -}} {{- end -}} @@ -27,10 +72,37 @@ ConfigMap name. Secret name. */}} {{- define "ocean-network-client.secretName" -}} -{{- if ne .Values.spotinst.account "" -}} -{{- .Values.oceanInfoData -}} +{{- if include "ocean-network-client.createSecret" . -}} + +{{/* +Validate oceanController.secretName was not provided in case we need to create secret. +*/}} +{{- if .Values.oceanController.secretName -}} +{{- fail "`oceanController.secretName` cannot be provided in case `spotinst.token` or `spotinst.account` are provided. Please use `secretName` instead" }} +{{- end -}} + +{{- default (include "ocean-network-client.fullname" .) .Values.secretName -}} {{- else -}} -{{ default (include "ocean-network-client.name" .) .Values.secretName }} + +{{/* +Validate both oceanController.secretName and secretName were not provided together with different values +*/}} +{{- if and .Values.oceanController.secretName .Values.secretName -}} +{{- if ne .Values.oceanController.secretName .Values.secretName -}} +{{- fail "Both `oceanController.secretName` and `secretName` were provided with different values. Please use `secretName`" }} +{{- end -}} +{{- end -}} + +{{- default "spotinst-kubernetes-cluster-controller" (default .Values.oceanController.secretName .Values.secretName) -}} +{{- end -}} +{{- end -}} + +{{/* +create Secret. +*/}} +{{- define "ocean-network-client.createSecret" -}} +{{- if or .Values.spotinst.token .Values.spotinst.account -}} +{{- true -}} {{- end -}} {{- end -}} diff --git a/charts/ocean-network-client/templates/configmap.yaml b/charts/ocean-network-client/templates/configmap.yaml index e294ca9..3722605 100644 --- a/charts/ocean-network-client/templates/configmap.yaml +++ b/charts/ocean-network-client/templates/configmap.yaml @@ -1,9 +1,9 @@ -{{ if ne .Values.spotinst.clusterIdentifier "" }} +{{ if include "ocean-network-client.createConfigMap" . }} apiVersion: v1 kind: ConfigMap metadata: name: {{ include "ocean-network-client.configMapName" . }} namespace: {{ include "ocean-network-client.namespace" . }} data: - spotinst.cluster-identifier: {{ .Values.spotinst.clusterIdentifier }} + spotinst.cluster-identifier: "{{ .Values.spotinst.clusterIdentifier }}" {{- end }} \ No newline at end of file diff --git a/charts/ocean-network-client/templates/daemon_set.yaml b/charts/ocean-network-client/templates/daemon_set.yaml index 72f934c..3247cf5 100644 --- a/charts/ocean-network-client/templates/daemon_set.yaml +++ b/charts/ocean-network-client/templates/daemon_set.yaml @@ -67,13 +67,11 @@ spec: secretKeyRef: name: {{ include "ocean-network-client.secretName" . }} key: token - optional: true - name: SPOTINST_ACCOUNT valueFrom: secretKeyRef: name: {{ include "ocean-network-client.secretName" . }} key: account - optional: true - name: SPOTINST_TOKEN_LEGACY valueFrom: configMapKeyRef: diff --git a/charts/ocean-network-client/templates/secret.yaml b/charts/ocean-network-client/templates/secret.yaml index 54a6e8b..cf68edb 100644 --- a/charts/ocean-network-client/templates/secret.yaml +++ b/charts/ocean-network-client/templates/secret.yaml @@ -1,4 +1,4 @@ -{{ if ne .Values.spotinst.account "" }} +{{ if include "ocean-network-client.createSecret" . }} apiVersion: v1 kind: Secret metadata: diff --git a/charts/ocean-network-client/values.yaml b/charts/ocean-network-client/values.yaml index ecd132f..e348846 100644 --- a/charts/ocean-network-client/values.yaml +++ b/charts/ocean-network-client/values.yaml @@ -1,15 +1,23 @@ -# -- (Optional) Namespace where components should be installed. +nameOverride: "" +fullnameOverride: "" +# -- (Optional) namespace override. namespace: kube-system -# -- (Optional) Secret name. -secretName: spotinst-kubernetes-cluster-controller -# -- (Optional) ConfigMap name. -configMapName: spotinst-kubernetes-cluster-controller-config +# -- Reference secret and configMap for the Ocean Controller. +# Deprecated in favor of secret and configMap objects +oceanController: + # -- (Optional) Secret name. Deprecated use secretName instead. + secretName: "" + # -- (Optional) ConfigMap name. Deprecated use configMapName instead + configMapName: "" +# -- (Optional) Secret name. +secretName: "" # -- (Optional) ConfigMap name. -oceanInfoData: spotinst-ocean-cluster +configMapName: "" # Spot Configuration. +# Will create secret and configMap objects. spotinst: # -- (Optional) Spot Token. # Ref: https://docs.spot.io/administration/api/create-api-token