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

fix: fixes limits templating in deployment chart + a quick test #154

Merged
merged 4 commits into from
Jun 13, 2024
Merged
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
8 changes: 7 additions & 1 deletion charts/clabernetes/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ data:
{{ .Values.globalConfig.deployment.resourcesByContainerlabKind | toYaml | indent 4 }}
privilegedLauncher: "{{ .Values.globalConfig.deployment.privilegedLauncher }}"
containerlabDebug: "{{ .Values.globalConfig.deployment.containerlabDebug }}"
{{- if .Values.globalConfig.deployment.containerlabTimeout }}
containerlabTimeout: {{ .Values.globalConfig.deployment.containerlabTimeout }}
{{- end }}
{{- if .Values.globalConfig.deployment.containerlabVersion }}
containerlabVersion: {{ .Values.globalConfig.deployment.containerlabVersion }}
{{- end }}
inClusterDNSSuffix: {{ .Values.globalConfig.inClusterDNSSuffix }}
imagePullThroughMode: {{ .Values.globalConfig.imagePull.imagePullThroughMode }}
{{- if .Values.globalConfig.deployment.launcherImage }}
launcherImage: {{ .Values.globalConfig.deployment.launcherImage }}
{{- end }}
launcherImagePullPolicy: {{ .Values.globalConfig.deployment.launcherImagePullPolicy }}
launcherLogLevel: {{ .Values.globalConfig.deployment.launcherLogLevel }}
{{- if .Values.globalConfig.imagePull.criSockOverride }}
Expand All @@ -49,5 +56,4 @@ data:
criKindOverride: {{ .Values.globalConfig.imagePull.criKindOverride }}
{{- end }}
naming: {{ .Values.globalConfig.naming }}
containerlabVersion: {{ .Values.globalConfig.deployment.containerlabVersion }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/clabernetes/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ spec:
cpu: {{ .Values.manager.resources.requests.cpu }}
{{- if .Values.manager.resources.limits }}
limits:
{{ toYaml .Values.manager.resources.limits | indent 14 }}
{{ toYaml .Values.manager.resources.limits | indent 12 }}
{{- end }}
containers:
- name: manager
Expand All @@ -124,7 +124,7 @@ spec:
cpu: {{ .Values.manager.resources.requests.cpu }}
{{- if .Values.manager.resources.limits }}
limits:
{{ toYaml .Values.manager.resources.limits | indent 14 }}
{{ toYaml .Values.manager.resources.limits | indent 12 }}
{{- end }}
ports:
- name: http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ data:
containerlabDebug: "false"
inClusterDNSSuffix: svc.cluster.local
imagePullThroughMode: auto
launcherImage:
launcherImagePullPolicy: IfNotPresent
launcherLogLevel: info
naming: prefixed
containerlabVersion:
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package default_values_test

import (
"fmt"
"os"
"path/filepath"
"testing"

clabernetesconstants "github.com/srl-labs/clabernetes/constants"
clabernetestesthelper "github.com/srl-labs/clabernetes/testhelper"
)

func TestMain(m *testing.M) {
clabernetestesthelper.Flags()

os.Exit(m.Run())
}

// TestCustomValues -- similar to the default one but we can just chuck in some custom values stuff
// in here to test lots of the helm rendering at once.
func TestCustomValues(t *testing.T) {
t.Parallel()

testName := "customized_values"
chartName := "clabernetes"

chartsDir, err := filepath.Abs("../../..")
if err != nil {
t.Error(err)
}

clabernetestesthelper.HelmTest(
t,
chartName,
testName,
clabernetesconstants.Clabernetes,
fmt.Sprintf("%s-values.yaml", testName),
chartsDir,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
manager:
resources:
limits:
memory: 256Mi
cpu: 100m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Source: clabernetes/templates/certificate-secret.yaml
apiVersion: v1
kind: Secret
metadata:
labels:
chart: "clabernetes-0.0.0"
release: release-name
heritage: Helm
revision: "1"
clabernetes/app: clabernetes
clabernetes/name: "clabernetes-certificate"
clabernetes/component: certificate
clabernetes/part-of: manager
name: "clabernetes-certificate"
data: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
# Source: clabernetes/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
chart: "clabernetes-0.0.0"
release: release-name
heritage: Helm
revision: "1"
clabernetes/app: clabernetes
clabernetes/name: "clabernetes-cluster-role"
clabernetes/component: cluster-role
name: "clabernetes-cluster-role"
rules:
- apiGroups:
- clabernetes.containerlab.dev
resources:
- "*"
verbs:
- "*"
- apiGroups:
- apiextensions.k8s.io
resources:
- "*"
verbs:
- "*"
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- apiGroups:
- ""
resources:
- namespaces
- secrets
- configmaps
- services
- pods
- persistentvolumeclaims
- serviceaccounts
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- rolebindings
verbs:
- get
- list
- create
- update
- delete
- patch
- watch
---
# Source: clabernetes/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
chart: "clabernetes-0.0.0"
release: release-name
heritage: Helm
revision: "1"
clabernetes/app: clabernetes
clabernetes/name: "clabernetes-launcher-role"
clabernetes/component: launcher-role
name: "clabernetes-launcher-role"
rules:
- apiGroups:
- clabernetes.containerlab.dev
resources:
- imagerequests
verbs:
- get
- create
- apiGroups:
- clabernetes.containerlab.dev
resources:
- connectivities
verbs:
- get
- watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# Source: clabernetes/templates/clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: clabernetes-manager
labels:
chart: "clabernetes-0.0.0"
release: release-name
heritage: Helm
revision: "1"
clabernetes/app: clabernetes
clabernetes/name: "clabernetes-cluster-role-binding"
clabernetes/component: cluster-role-binding
subjects:
- kind: ServiceAccount
name: "clabernetes-service-account"
namespace: clabernetes
roleRef:
kind: ClusterRole
name: "clabernetes-cluster-role"
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# Source: clabernetes/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: clabernetes-config
namespace: clabernetes
labels:
chart: "clabernetes-0.0.0"
release: release-name
heritage: Helm
revision: "1"
clabernetes/app: clabernetes
clabernetes/name: "clabernetes-config"
clabernetes/component: config
data:
mergeMode: merge
globalAnnotations: |-
---
{}
globalLabels: |-
---
{}
resourcesDefault: |-
---
requests:
cpu: 200m
memory: 512Mi
resourcesByContainerlabKind: |-
---
{}
privilegedLauncher: "true"
containerlabDebug: "false"
inClusterDNSSuffix: svc.cluster.local
imagePullThroughMode: auto
launcherImagePullPolicy: IfNotPresent
launcherLogLevel: info
naming: prefixed
Loading