Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/network client 1.1 #138

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/ocean-network-client/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 22 additions & 7 deletions charts/ocean-network-client/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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.
Expand All @@ -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 |
Expand Down
15 changes: 13 additions & 2 deletions charts/ocean-network-client/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion charts/ocean-network-client/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
88 changes: 80 additions & 8 deletions charts/ocean-network-client/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,107 @@
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 -}}

{{/*
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 -}}

Expand Down
4 changes: 2 additions & 2 deletions charts/ocean-network-client/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 0 additions & 2 deletions charts/ocean-network-client/templates/daemon_set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charts/ocean-network-client/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if ne .Values.spotinst.account "" }}
{{ if include "ocean-network-client.createSecret" . }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
20 changes: 14 additions & 6 deletions charts/ocean-network-client/values.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down