Skip to content

Commit

Permalink
Feature/con 27268 network client 1.1 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
baruchis123 committed Jun 23, 2024
1 parent 256e77e commit 910efbd
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 21 deletions.
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.24
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
27 changes: 22 additions & 5 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.24](https://img.shields.io/badge/Version-1.0.24-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,14 +41,20 @@ helm install my-release spot/ocean-network-client

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| configMapName | Optional | `""` | ConfigMap name to use. In case spotinst.clusterIdentifier is provided, this overrides the name of the created configMap. |
| 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. |
| oceanController.configMapName | Optional | `"spotinst-kubernetes-cluster-controller-config"` | ConfigMap name. |
| oceanController.secretName | Optional | `"spotinst-kubernetes-cluster-controller"` | Secret name. |
| oceanController | object | `{"configMapName":"","secretName":""}` | Reference secret and configMap for the Ocean Controller. Deprecated in favor of spotinst object or secretName and configMapName |
| 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 | `""` | Secret name to use. In case spotinst.token, spotinst.account are provided, this overrides the name of the created secret. |
| 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 |
| tolerations | Optional | `[{"operator":"Exists"}]` | Tolerations - Enable pods to run an all nodes in cluster Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ |

----------------------------------------------
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.
92 changes: 86 additions & 6 deletions charts/ocean-network-client/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,109 @@
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" -}}
{{ default (include "ocean-network-client.name" .) .Values.oceanController.configMapName }}
{{- end }}
{{- 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 -}}

{{/*
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" -}}
{{ default (include "ocean-network-client.name" .) .Values.oceanController.secretName }}
{{- end }}
{{- 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 -}}

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

{{/*
DaemonSet labels.
Expand Down
9 changes: 9 additions & 0 deletions charts/ocean-network-client/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ 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 }}"
{{- 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
11 changes: 11 additions & 0 deletions charts/ocean-network-client/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ if include "ocean-network-client.createSecret" . }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "ocean-network-client.secretName" . }}
namespace: {{ include "ocean-network-client.namespace" . }}
type: Opaque
data:
token: {{ .Values.spotinst.token | b64enc }}
account: {{ .Values.spotinst.account | b64enc }}
{{- end }}
32 changes: 28 additions & 4 deletions charts/ocean-network-client/values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
# -- (Optional) Namespace where components should be installed.
namespace: kube-system

# -- Reference secret and configMap for the Ocean Controller.
# Deprecated in favor of spotinst object or secretName and configMapName
oceanController:
# -- (Optional) Secret name.
secretName: spotinst-kubernetes-cluster-controller
# -- (Optional) ConfigMap name.
configMapName: spotinst-kubernetes-cluster-controller-config
# -- (Optional) Secret name. Deprecated use secretName instead.
secretName: ""
# -- (Optional) ConfigMap name. Deprecated use configMapName instead
configMapName: ""

# -- (Optional) Secret name to use.
# In case spotinst.token, spotinst.account are provided, this overrides the name of the created secret.
secretName: ""
# -- (Optional) ConfigMap name to use.
# In case spotinst.clusterIdentifier is provided, this overrides the name of the created configMap.
configMapName: ""

# Spot Configuration.
# Will create secret and configMap objects.
spotinst:
# -- (Optional) Spot Token.
# Ref: https://docs.spot.io/administration/api/create-api-token
token: ""
# -- (Optional) Spot Account.
# Ref: https://docs.spot.io/administration/organizations?id=account
account: ""
# -- (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/
clusterIdentifier: ""


image:
# -- (Optional) Image repository.
Expand Down

0 comments on commit 910efbd

Please sign in to comment.