mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-23 23:08:35 +00:00
⚡ Template hostPort
(s) in the Helm chart
This commit is contained in:
parent
f68fed0de8
commit
139336d4ee
@ -259,6 +259,30 @@ func template(object interface{}, mappings map[string]interface{}) (template int
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleHubPod(manifest string) string {
|
||||||
|
lines := strings.Split(manifest, "\n")
|
||||||
|
|
||||||
|
for i, line := range lines {
|
||||||
|
if strings.HasPrefix(strings.TrimSpace(line), "hostPort:") {
|
||||||
|
lines[i] = " hostPort: {{ .Values.tap.proxy.hub.srvport }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(lines, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleFrontPod(manifest string) string {
|
||||||
|
lines := strings.Split(manifest, "\n")
|
||||||
|
|
||||||
|
for i, line := range lines {
|
||||||
|
if strings.HasPrefix(strings.TrimSpace(line), "hostPort:") {
|
||||||
|
lines[i] = " hostPort: {{ .Values.tap.proxy.front.srvport }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(lines, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
func handlePVCManifest(manifest string) string {
|
func handlePVCManifest(manifest string) string {
|
||||||
return fmt.Sprintf("{{- if .Values.tap.persistentstorage }}\n%s{{- end }}\n", manifest)
|
return fmt.Sprintf("{{- if .Values.tap.persistentstorage }}\n%s{{- end }}\n", manifest)
|
||||||
}
|
}
|
||||||
@ -282,6 +306,14 @@ func handleDaemonSetManifest(manifest string) string {
|
|||||||
if strings.TrimSpace(line) == "claimName: kubeshark-persistent-volume-claim" {
|
if strings.TrimSpace(line) == "claimName: kubeshark-persistent-volume-claim" {
|
||||||
lines[i] = fmt.Sprintf("%s\n{{- end }}", line)
|
lines[i] = fmt.Sprintf("%s\n{{- end }}", line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(strings.TrimSpace(line), "- containerPort:") {
|
||||||
|
lines[i] = " - containerPort: {{ .Values.tap.proxy.worker.srvport }}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(strings.TrimSpace(line), "hostPort:") {
|
||||||
|
lines[i] = " hostPort: {{ .Values.tap.proxy.worker.srvport }}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(lines, "\n")
|
return strings.Join(lines, "\n")
|
||||||
@ -315,6 +347,14 @@ func dumpHelmChart(objects map[string]interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if filename == "04-hub-pod.yaml" {
|
||||||
|
manifest = handleHubPod(manifest)
|
||||||
|
}
|
||||||
|
|
||||||
|
if filename == "06-front-pod.yaml" {
|
||||||
|
manifest = handleFrontPod(manifest)
|
||||||
|
}
|
||||||
|
|
||||||
if filename == "08-persistent-volume-claim.yaml" {
|
if filename == "08-persistent-volume-claim.yaml" {
|
||||||
manifest = handlePVCManifest(manifest)
|
manifest = handlePVCManifest(manifest)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ spec:
|
|||||||
name: kubeshark-hub
|
name: kubeshark-hub
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
hostPort: 8898
|
hostPort: {{ .Values.tap.proxy.hub.srvport }}
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: '{{ .Values.tap.resources.hub.limits.cpu }}'
|
cpu: '{{ .Values.tap.resources.hub.limits.cpu }}'
|
||||||
|
@ -24,7 +24,7 @@ spec:
|
|||||||
name: kubeshark-front
|
name: kubeshark-front
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
hostPort: 8899
|
hostPort: {{ .Values.tap.proxy.front.srvport }}
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
failureThreshold: 3
|
failureThreshold: 3
|
||||||
periodSeconds: 1
|
periodSeconds: 1
|
||||||
|
@ -43,8 +43,8 @@ spec:
|
|||||||
imagePullPolicy: '{{ .Values.tap.docker.imagepullpolicy }}'
|
imagePullPolicy: '{{ .Values.tap.docker.imagepullpolicy }}'
|
||||||
name: kubeshark-worker-daemon-set
|
name: kubeshark-worker-daemon-set
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: {{ .Values.tap.proxy.worker.srvport }}
|
||||||
hostPort: 8897
|
hostPort: {{ .Values.tap.proxy.worker.srvport }}
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: '{{ .Values.tap.resources.worker.limits.cpu }}'
|
cpu: '{{ .Values.tap.resources.worker.limits.cpu }}'
|
||||||
|
@ -879,7 +879,7 @@ func (provider *Provider) BuildWorkerDaemonSet(
|
|||||||
Image: podImage,
|
Image: podImage,
|
||||||
Ports: []core.ContainerPort{{
|
Ports: []core.ContainerPort{{
|
||||||
HostPort: int32(config.Config.Tap.Proxy.Worker.SrvPort),
|
HostPort: int32(config.Config.Tap.Proxy.Worker.SrvPort),
|
||||||
ContainerPort: configStructs.ContainerPort,
|
ContainerPort: int32(config.Config.Tap.Proxy.Worker.SrvPort),
|
||||||
}},
|
}},
|
||||||
ImagePullPolicy: imagePullPolicy,
|
ImagePullPolicy: imagePullPolicy,
|
||||||
VolumeMounts: volumeMounts,
|
VolumeMounts: volumeMounts,
|
||||||
|
@ -43,7 +43,7 @@ spec:
|
|||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
name: kubeshark-worker-daemon-set
|
name: kubeshark-worker-daemon-set
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 8897
|
||||||
hostPort: 8897
|
hostPort: 8897
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
|
Loading…
Reference in New Issue
Block a user