Skip to content

Commit

Permalink
Add configurable Livenessprobe support to helm chart (aws#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgchinmay authored Feb 3, 2021
1 parent 0980ae2 commit 771b52e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/helm/appmesh-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,4 @@ Parameter | Description | Default
`xray.image.tag` | X-Ray image tag | `latest`
`accountId` | AWS Account ID for the Kubernetes cluster | None
`env` | environment variables to be injected into the appmesh-controller pod | `{}`
`livenessProbe` | Liveness probe settings for the controller | (see `values.yaml`)
4 changes: 4 additions & 0 deletions config/helm/appmesh-controller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ spec:
- --aws-account-id={{ .Values.accountId }}
{{- end }}
- --sidecar-log-level={{ .Values.sidecar.logLevel }}
# this must be same as livenessProbe port which can be configured
- --health-probe-port={{ .Values.livenessProbe.httpGet.port }}
{{- if .Values.env }}
env:
{{- range $key, $value := .Values.env }}
Expand All @@ -113,6 +115,8 @@ spec:
{{- end}}
resources:
{{ toYaml .Values.resources | indent 10 }}
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 10 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
Expand Down
10 changes: 10 additions & 0 deletions config/helm/appmesh-controller/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,13 @@ env: {}
# http_proxy: http://proxyserver:3128
# https_proxy: http://proxyserver:3128
# no_proxy: "localhost,127.0.0.1,.cluster.local"

# Liveness probe configuration for the appmesh-controller pod
livenessProbe:
failureThreshold: 2
httpGet:
path: /healthz
port: 61779
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 10
10 changes: 10 additions & 0 deletions config/helm/appmesh-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,13 @@ env: {}
# http_proxy: http://proxyserver:3128
# https_proxy: http://proxyserver:3128
# no_proxy: "localhost,127.0.0.1,.cluster.local"

# Liveness probe configuration for the controller
livenessProbe:
failureThreshold: 2
httpGet:
path: /healthz
port: 61779
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 10
15 changes: 10 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"os"
"strconv"
"time"

"github.com/aws/aws-app-mesh-controller-for-k8s/pkg/aws/throttle"
Expand Down Expand Up @@ -60,8 +61,8 @@ import (
)

const (
flagHealthProbeBindAddr = "health-probe-bind-addr"
defaultHealthProbeBindAddress = ":61779"
flagHealthProbePort = "health-probe-port"
defaultHealthProbePort = 61779
)

var (
Expand All @@ -83,7 +84,7 @@ func main() {
var enableCustomHealthCheck bool
var logLevel string
var listPageLimit int64
var healthProbeBindAddress string
var healthProbePort int
awsCloudConfig := aws.CloudConfig{ThrottleConfig: throttle.NewDefaultServiceOperationsThrottleConfig()}
injectConfig := inject.Config{}
cloudMapConfig := cloudmap.Config{}
Expand All @@ -98,8 +99,8 @@ func main() {
fs.StringVar(&logLevel, "log-level", "info", "Set the controller log level - info(default), debug")
fs.Int64Var(&listPageLimit, "page-limit", 100,
"The page size limiting the number of response for list operation to API Server")
fs.StringVar(&healthProbeBindAddress, flagHealthProbeBindAddr, defaultHealthProbeBindAddress,
"The address the health probes binds to.")
fs.IntVar(&healthProbePort, flagHealthProbePort, defaultHealthProbePort,
"The port the health probes binds to.")

awsCloudConfig.BindFlags(fs)
injectConfig.BindFlags(fs)
Expand All @@ -124,6 +125,10 @@ func main() {
"BuildDate", version.BuildDate,
)

parsedPort := strconv.Itoa(healthProbePort)
healthProbeBindAddress := ":" + parsedPort
setupLog.Info("Health endpoint", "HealthProbeBindAddress", healthProbeBindAddress)

eventNotificationChan := make(chan k8s.GenericEvent)

kubeConfig := ctrl.GetConfigOrDie()
Expand Down

0 comments on commit 771b52e

Please sign in to comment.