(feat) Add Promtail and Netshoot addons (#1058)
* add promtail addon * Add Netshoot addon * update common to include envList for addons * Add basic promtail and netshoot unittests
This commit is contained in:
@@ -15,4 +15,4 @@ maintainers:
|
|||||||
name: common
|
name: common
|
||||||
sources: null
|
sources: null
|
||||||
type: library
|
type: library
|
||||||
version: 8.0.10
|
version: 8.0.11
|
||||||
|
|||||||
@@ -12,8 +12,16 @@ imagePullPolicy: {{ .Values.codeserverImage.pullPolicy }}
|
|||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml . | nindent 2 }}
|
{{- toYaml . | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.addons.codeserver.env }}
|
|
||||||
env:
|
env:
|
||||||
|
{{- range $envList := .Values.addons.codeserver.envList }}
|
||||||
|
{{- if and $envList.name $envList.value }}
|
||||||
|
- name: {{ $envList.name }}
|
||||||
|
value: {{ $envList.value | quote }}
|
||||||
|
{{- else }}
|
||||||
|
{{- fail "Please specify name/value for codeserver environment variable" }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end}}
|
||||||
|
{{- with .Values.addons.codeserver.env }}
|
||||||
{{- range $k, $v := . }}
|
{{- range $k, $v := . }}
|
||||||
- name: {{ $k }}
|
- name: {{ $k }}
|
||||||
value: {{ $v | quote }}
|
value: {{ $v | quote }}
|
||||||
|
|||||||
@@ -9,8 +9,17 @@ imagePullPolicy: {{ .Values.netshootImage.pullPolicy }}
|
|||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml . | nindent 2 }}
|
{{- toYaml . | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.addons.netshoot.env }}
|
|
||||||
env:
|
env:
|
||||||
|
{{- range $envList := .Values.addons.netshoot.envList }}
|
||||||
|
{{- if and $envList.name $envList.value }}
|
||||||
|
- name: {{ $envList.name }}
|
||||||
|
value: {{ $envList.value | quote }}
|
||||||
|
{{- else }}
|
||||||
|
{{- fail "Please specify name/value for netshoot environment variable" }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end}}
|
||||||
|
{{- with .Values.addons.netshoot.env }}
|
||||||
{{- range $k, $v := . }}
|
{{- range $k, $v := . }}
|
||||||
- name: {{ $k }}
|
- name: {{ $k }}
|
||||||
value: {{ $v | quote }}
|
value: {{ $v | quote }}
|
||||||
|
|||||||
@@ -12,8 +12,17 @@ imagePullPolicy: {{ .Values.promtailImage.pullPolicy }}
|
|||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml . | nindent 2 }}
|
{{- toYaml . | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.addons.promtail.env }}
|
|
||||||
env:
|
env:
|
||||||
|
{{- range $envList := .Values.addons.promtail.envList }}
|
||||||
|
{{- if and $envList.name $envList.value }}
|
||||||
|
- name: {{ $envList.name }}
|
||||||
|
value: {{ $envList.value | quote }}
|
||||||
|
{{- else }}
|
||||||
|
{{- fail "Please specify name/value for promtail environment variable" }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end}}
|
||||||
|
{{- with .Values.addons.promtail.env }}
|
||||||
{{- range $k, $v := . }}
|
{{- range $k, $v := . }}
|
||||||
- name: {{ $k }}
|
- name: {{ $k }}
|
||||||
value: {{ $v | quote }}
|
value: {{ $v | quote }}
|
||||||
|
|||||||
@@ -726,7 +726,7 @@ addons:
|
|||||||
# -- All variables specified here will be added to the vpn sidecar container
|
# -- All variables specified here will be added to the vpn sidecar container
|
||||||
# See the documentation of the VPN image for all config values
|
# See the documentation of the VPN image for all config values
|
||||||
envList: []
|
envList: []
|
||||||
# name: someenv
|
#- name: someenv
|
||||||
# value: somevalue
|
# value: somevalue
|
||||||
|
|
||||||
# -- Provide a customized vpn configuration file to be used by the VPN.
|
# -- Provide a customized vpn configuration file to be used by the VPN.
|
||||||
@@ -750,6 +750,12 @@ addons:
|
|||||||
# -- Set any environment variables for code-server here
|
# -- Set any environment variables for code-server here
|
||||||
env: {}
|
env: {}
|
||||||
# TZ: UTC
|
# TZ: UTC
|
||||||
|
|
||||||
|
# -- All variables specified here will be added to the codeserver sidecar container
|
||||||
|
# See the documentation of the codeserver image for all config values
|
||||||
|
envList: []
|
||||||
|
#- name: someenv
|
||||||
|
# value: somevalue
|
||||||
# -- Set codeserver command line arguments.
|
# -- Set codeserver command line arguments.
|
||||||
# Consider setting --user-data-dir to a persistent location to preserve code-server setting changes
|
# Consider setting --user-data-dir to a persistent location to preserve code-server setting changes
|
||||||
args:
|
args:
|
||||||
@@ -825,6 +831,11 @@ addons:
|
|||||||
enabled: false
|
enabled: false
|
||||||
# -- Set any environment variables for promtail here
|
# -- Set any environment variables for promtail here
|
||||||
env: {}
|
env: {}
|
||||||
|
# -- All variables specified here will be added to the promtail sidecar container
|
||||||
|
# See the documentation of the promtail image for all config values
|
||||||
|
envList: []
|
||||||
|
#- name: someenv
|
||||||
|
# value: somevalue
|
||||||
# -- Set promtail command line arguments
|
# -- Set promtail command line arguments
|
||||||
args: []
|
args: []
|
||||||
# -- The URL to Loki
|
# -- The URL to Loki
|
||||||
@@ -852,6 +863,11 @@ addons:
|
|||||||
|
|
||||||
# -- Set any environment variables for netshoot here
|
# -- Set any environment variables for netshoot here
|
||||||
env: {}
|
env: {}
|
||||||
|
# -- All variables specified here will be added to the netshoot sidecar container
|
||||||
|
# See the documentation of the netshoot image for all config values
|
||||||
|
envList: []
|
||||||
|
#- name: someenv
|
||||||
|
# value: somevalue
|
||||||
|
|
||||||
securityContext:
|
securityContext:
|
||||||
capabilities:
|
capabilities:
|
||||||
|
|||||||
@@ -133,3 +133,128 @@
|
|||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
- variable: promtail
|
||||||
|
label: "Promtail"
|
||||||
|
schema:
|
||||||
|
type: dict
|
||||||
|
attrs:
|
||||||
|
- variable: enabled
|
||||||
|
label: "enabled"
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
show_subquestions_if: true
|
||||||
|
subquestions:
|
||||||
|
- variable: envList
|
||||||
|
label: "Promtail environment Variables"
|
||||||
|
schema:
|
||||||
|
type: list
|
||||||
|
show_if: [["type", "!=", "disabled"]]
|
||||||
|
default: []
|
||||||
|
items:
|
||||||
|
- variable: loki
|
||||||
|
label: "Loki URL"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: envItem
|
||||||
|
label: "Environment Variable"
|
||||||
|
schema:
|
||||||
|
type: dict
|
||||||
|
attrs:
|
||||||
|
- variable: name
|
||||||
|
label: "Name"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: value
|
||||||
|
label: "Value"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: args
|
||||||
|
label: "Promtail ecommand line arguments"
|
||||||
|
schema:
|
||||||
|
type: list
|
||||||
|
show_if: [["type", "!=", "disabled"]]
|
||||||
|
default: []
|
||||||
|
items:
|
||||||
|
- variable: arg
|
||||||
|
label: "Arg"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: logs
|
||||||
|
label: "Log Paths"
|
||||||
|
schema:
|
||||||
|
type: dict
|
||||||
|
attrs:
|
||||||
|
- variable: name
|
||||||
|
label: "Name"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: path
|
||||||
|
label: "Path"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: volumeMounts
|
||||||
|
label: "volumeMounts"
|
||||||
|
description: "At least 1 volumeMount is required!"
|
||||||
|
schema:
|
||||||
|
type: dict
|
||||||
|
attrs:
|
||||||
|
- variable: name
|
||||||
|
label: "Name"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: mountPath
|
||||||
|
label: "mountPath"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: readOnly
|
||||||
|
label: "readOnly"
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
hidden: true
|
||||||
|
|
||||||
|
- variable: netshoot
|
||||||
|
label: "Netshoot"
|
||||||
|
schema:
|
||||||
|
type: dict
|
||||||
|
attrs:
|
||||||
|
- variable: enabled
|
||||||
|
label: "enabled"
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
show_subquestions_if: true
|
||||||
|
subquestions:
|
||||||
|
- variable: envList
|
||||||
|
label: "Netshoot environment Variables"
|
||||||
|
schema:
|
||||||
|
type: list
|
||||||
|
show_if: [["type", "!=", "disabled"]]
|
||||||
|
default: []
|
||||||
|
items:
|
||||||
|
- variable: envItem
|
||||||
|
label: "Environment Variable"
|
||||||
|
schema:
|
||||||
|
type: dict
|
||||||
|
attrs:
|
||||||
|
- variable: name
|
||||||
|
label: "Name"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- variable: value
|
||||||
|
label: "Value"
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
require_relative '../../test_helper'
|
||||||
|
|
||||||
|
class Test < ChartTest
|
||||||
|
@@chart = Chart.new('charts/library/common-test')
|
||||||
|
|
||||||
|
describe @@chart.name do
|
||||||
|
describe 'addon::netshoot' do
|
||||||
|
it 'defaults to disabled' do
|
||||||
|
deployment = chart.resources(kind: "Deployment").first
|
||||||
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
||||||
|
netshootContainer = containers.find{ |c| c["name"] == "netshoot" }
|
||||||
|
|
||||||
|
assert_nil(netshootContainer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'netshoot can be enabled' do
|
||||||
|
values = {
|
||||||
|
addons: {
|
||||||
|
netshoot: {
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chart.value values
|
||||||
|
deployment = chart.resources(kind: "Deployment").first
|
||||||
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
||||||
|
netshootContainer = containers.find{ |c| c["name"] == "netshoot" }
|
||||||
|
|
||||||
|
refute_nil(netshootContainer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
require_relative '../../test_helper'
|
||||||
|
|
||||||
|
class Test < ChartTest
|
||||||
|
@@chart = Chart.new('charts/library/common-test')
|
||||||
|
|
||||||
|
describe @@chart.name do
|
||||||
|
describe 'addon::promtail' do
|
||||||
|
it 'defaults to disabled' do
|
||||||
|
deployment = chart.resources(kind: "Deployment").first
|
||||||
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
||||||
|
promtailContainer = containers.find{ |c| c["name"] == "promtail" }
|
||||||
|
|
||||||
|
assert_nil(promtailContainer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'promtail can be enabled' do
|
||||||
|
values = {
|
||||||
|
addons: {
|
||||||
|
promtail: {
|
||||||
|
enabled: true,
|
||||||
|
volumeMounts: [
|
||||||
|
{
|
||||||
|
name: "config",
|
||||||
|
mountPath: "/tmp",
|
||||||
|
readOnly: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chart.value values
|
||||||
|
deployment = chart.resources(kind: "Deployment").first
|
||||||
|
containers = deployment["spec"]["template"]["spec"]["containers"]
|
||||||
|
promtailContainer = containers.find{ |c| c["name"] == "promtail" }
|
||||||
|
|
||||||
|
refute_nil(promtailContainer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user