diff --git a/charts/actions-runner-controller/templates/deployment.yaml b/charts/actions-runner-controller/templates/deployment.yaml index 4e17a8548e..b08ed16f91 100644 --- a/charts/actions-runner-controller/templates/deployment.yaml +++ b/charts/actions-runner-controller/templates/deployment.yaml @@ -144,6 +144,18 @@ spec: name: metrics-port protocol: TCP {{- end }} + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 resources: {{- toYaml .Values.resources | nindent 12 }} securityContext: diff --git a/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl b/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl index 2c6461b76b..3b68f2c95e 100644 --- a/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl +++ b/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl @@ -92,6 +92,18 @@ args: ports: {{- toYaml $ports | nindent 2 }} {{- end }} +livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 +readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 env: - name: CONTROLLER_MANAGER_CONTAINER_IMAGE value: "{{ .Values.controller.manager.container.image }}" diff --git a/charts/gha-runner-scale-set-controller/templates/deployment.yaml b/charts/gha-runner-scale-set-controller/templates/deployment.yaml index 200cbe0f6b..222ee0617f 100644 --- a/charts/gha-runner-scale-set-controller/templates/deployment.yaml +++ b/charts/gha-runner-scale-set-controller/templates/deployment.yaml @@ -101,6 +101,18 @@ spec: protocol: TCP name: metrics {{- end }} + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 env: - name: CONTROLLER_MANAGER_CONTAINER_IMAGE value: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index f90df347f2..a8010c856f 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -56,6 +56,18 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 volumeMounts: - name: controller-manager mountPath: "/etc/actions-runner-controller" diff --git a/main.go b/main.go index 116f292089..fcc5ddbf2a 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/healthz" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" // +kubebuilder:scaffold:imports @@ -83,6 +84,7 @@ func main() { listenerMetricsEndpoint string metricsAddr string + probeAddr string autoScalingRunnerSetOnly bool enableLeaderElection bool disableAdmissionWebhook bool @@ -121,6 +123,7 @@ func main() { flag.StringVar(&listenerMetricsAddr, "listener-metrics-addr", ":8080", "The address applied to AutoscalingListener metrics server") flag.StringVar(&listenerMetricsEndpoint, "listener-metrics-endpoint", "/metrics", "The AutoscalingListener metrics server endpoint from which the metrics are collected") flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") + flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the health probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") flag.StringVar(&leaderElectionID, "leader-election-id", "actions-runner-controller", "Controller id for leader election.") @@ -239,9 +242,10 @@ func main() { SyncPeriod: &syncPeriod, DefaultNamespaces: defaultNamespaces, }, - WebhookServer: webhookServer, - LeaderElection: enableLeaderElection, - LeaderElectionID: leaderElectionID, + WebhookServer: webhookServer, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, + LeaderElectionID: leaderElectionID, Client: client.Options{ Cache: &client.CacheOptions{ DisableFor: []client.Object{ @@ -256,6 +260,15 @@ func main() { os.Exit(1) } + if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { + log.Error(err, "unable to set up health check") + os.Exit(1) + } + if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { + log.Error(err, "unable to set up ready check") + os.Exit(1) + } + if autoScalingRunnerSetOnly { if err := actionsgithubcom.SetupIndexers(mgr); err != nil { log.Error(err, "unable to setup indexers")