diff --git a/cmd/db-manager/v1beta1/Dockerfile b/cmd/db-manager/v1beta1/Dockerfile index bc1a51eb48a..33424cec9bb 100644 --- a/cmd/db-manager/v1beta1/Dockerfile +++ b/cmd/db-manager/v1beta1/Dockerfile @@ -2,7 +2,6 @@ FROM golang:alpine AS build-env ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 WORKDIR /go/src/github.com/kubeflow/katib @@ -18,13 +17,8 @@ COPY pkg/ pkg/ # Build the binary. RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -a -o katib-db-manager ./cmd/db-manager/v1beta1 -# Add GRPC health probe. -RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - # Copy the db-manager into a thin image. FROM alpine:3.15 WORKDIR /app -COPY --from=build-env /bin/grpc_health_probe /bin/ COPY --from=build-env /go/src/github.com/kubeflow/katib/katib-db-manager /app/ ENTRYPOINT ["./katib-db-manager"] diff --git a/cmd/suggestion/goptuna/v1beta1/Dockerfile b/cmd/suggestion/goptuna/v1beta1/Dockerfile index 82dc9893c96..553a26a0fe1 100644 --- a/cmd/suggestion/goptuna/v1beta1/Dockerfile +++ b/cmd/suggestion/goptuna/v1beta1/Dockerfile @@ -2,7 +2,6 @@ FROM golang:alpine AS build-env ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 WORKDIR /go/src/github.com/kubeflow/katib @@ -18,10 +17,6 @@ COPY pkg/ pkg/ # Build the binary. RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o goptuna-suggestion ./cmd/suggestion/goptuna/v1beta1 -# Add GRPC health probe. -RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - # Copy the Goptuna suggestion into a thin image. FROM alpine:3.15 @@ -29,7 +24,6 @@ ENV TARGET_DIR /opt/katib WORKDIR ${TARGET_DIR} -COPY --from=build-env /bin/grpc_health_probe /bin/ COPY --from=build-env /go/src/github.com/kubeflow/katib/goptuna-suggestion ${TARGET_DIR}/ RUN chgrp -R 0 ${TARGET_DIR} \ diff --git a/cmd/suggestion/hyperband/v1beta1/Dockerfile b/cmd/suggestion/hyperband/v1beta1/Dockerfile index 71ea744a9d9..374410caf6a 100644 --- a/cmd/suggestion/hyperband/v1beta1/Dockerfile +++ b/cmd/suggestion/hyperband/v1beta1/Dockerfile @@ -1,11 +1,3 @@ -FROM alpine:3.15 AS downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH @@ -22,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "arm64" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/cmd/suggestion/hyperopt/v1beta1/Dockerfile b/cmd/suggestion/hyperopt/v1beta1/Dockerfile index 40c37c0d523..3d76a025fde 100644 --- a/cmd/suggestion/hyperopt/v1beta1/Dockerfile +++ b/cmd/suggestion/hyperopt/v1beta1/Dockerfile @@ -1,11 +1,3 @@ -FROM alpine:3.15 AS downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH @@ -22,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/cmd/suggestion/nas/darts/v1beta1/Dockerfile b/cmd/suggestion/nas/darts/v1beta1/Dockerfile index 60ac0123ba6..5889b01981c 100644 --- a/cmd/suggestion/nas/darts/v1beta1/Dockerfile +++ b/cmd/suggestion/nas/darts/v1beta1/Dockerfile @@ -1,11 +1,3 @@ -FROM alpine:3.15 as downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH @@ -22,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/cmd/suggestion/nas/enas/v1beta1/Dockerfile b/cmd/suggestion/nas/enas/v1beta1/Dockerfile index 7b171d2d4c9..6e5c425669c 100644 --- a/cmd/suggestion/nas/enas/v1beta1/Dockerfile +++ b/cmd/suggestion/nas/enas/v1beta1/Dockerfile @@ -1,17 +1,8 @@ -FROM alpine:3.15 AS downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/nas/enas/v1beta1 -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ @@ -23,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/cmd/suggestion/optuna/v1beta1/Dockerfile b/cmd/suggestion/optuna/v1beta1/Dockerfile index 2197ac7f2d8..85cdb75c842 100644 --- a/cmd/suggestion/optuna/v1beta1/Dockerfile +++ b/cmd/suggestion/optuna/v1beta1/Dockerfile @@ -1,11 +1,3 @@ -FROM alpine:3.15 AS downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH @@ -22,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/cmd/suggestion/pbt/v1beta1/Dockerfile b/cmd/suggestion/pbt/v1beta1/Dockerfile index 8cd320034e8..43a3f155798 100644 --- a/cmd/suggestion/pbt/v1beta1/Dockerfile +++ b/cmd/suggestion/pbt/v1beta1/Dockerfile @@ -1,11 +1,3 @@ -FROM alpine:3.15 AS downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH @@ -22,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/cmd/suggestion/skopt/v1beta1/Dockerfile b/cmd/suggestion/skopt/v1beta1/Dockerfile index 062ead68775..2105102cae9 100644 --- a/cmd/suggestion/skopt/v1beta1/Dockerfile +++ b/cmd/suggestion/skopt/v1beta1/Dockerfile @@ -1,11 +1,3 @@ -FROM alpine:3.15 AS downloader - -ARG TARGETARCH -ENV GRPC_HEALTH_PROBE_VERSION v0.4.15 - -RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ - && chmod +x /bin/grpc_health_probe - FROM python:3.10-slim ARG TARGETARCH @@ -22,7 +14,6 @@ RUN if [ "${TARGETARCH}" = "ppc64le" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ -COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} diff --git a/manifests/v1beta1/components/db-manager/db-manager.yaml b/manifests/v1beta1/components/db-manager/db-manager.yaml index 41b8b3f9307..f4e6e455b0b 100644 --- a/manifests/v1beta1/components/db-manager/db-manager.yaml +++ b/manifests/v1beta1/components/db-manager/db-manager.yaml @@ -35,8 +35,8 @@ spec: - name: api containerPort: 6789 livenessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:6789"] + grpc: + port: 6789 initialDelaySeconds: 10 periodSeconds: 60 failureThreshold: 5 diff --git a/pkg/controller.v1beta1/consts/const.go b/pkg/controller.v1beta1/consts/const.go index 50f3621f1f7..7da1da25d8a 100644 --- a/pkg/controller.v1beta1/consts/const.go +++ b/pkg/controller.v1beta1/consts/const.go @@ -87,10 +87,6 @@ const ( // DefaultEarlyStoppingPort is the default port of EarlyStopping service. DefaultEarlyStoppingPort = 6788 - // DefaultGRPCService is the default suggestion service name, - // which is used to run healthz check using grpc probe. - DefaultGRPCService = "manager.v1beta1.Suggestion" - // DefaultGRPCRetryAttempts is the the maximum number of retries for gRPC calls DefaultGRPCRetryAttempts = 10 // DefaultGRPCRetryPeriod is a fixed period of time between gRPC call retries @@ -171,6 +167,10 @@ var ( // DefaultKatibDBManagerServicePort is the default Port of Katib DB Manager DefaultKatibDBManagerServicePort = env.GetEnvOrDefault(DefaultKatibDBManagerServicePortEnvName, "6789") + // DefaultGRPCService is the default suggestion service name, + // which is used to run healthz check using grpc probe. + DefaultGRPCService = "manager.v1beta1.Suggestion" + // List of all valid keys of trial metadata for substitution in Trial template TrialTemplateMetaKeys = []string{ TrialTemplateMetaKeyOfName, diff --git a/pkg/controller.v1beta1/suggestion/composer/composer.go b/pkg/controller.v1beta1/suggestion/composer/composer.go index 79c262078b3..139fc529df7 100644 --- a/pkg/controller.v1beta1/suggestion/composer/composer.go +++ b/pkg/controller.v1beta1/suggestion/composer/composer.go @@ -44,8 +44,6 @@ const ( defaultPeriodForReady = 10 defaultPeriodForLive = 120 defaultFailureThreshold = 12 - // Ref https://github.com/grpc-ecosystem/grpc-health-probe/ - defaultGRPCHealthCheckProbe = "/bin/grpc_health_probe" ) var ( @@ -210,12 +208,9 @@ func (g *General) desiredContainers(s *suggestionsv1beta1.Suggestion, if viper.GetBool(consts.ConfigEnableGRPCProbeInSuggestion) && suggestionContainer.ReadinessProbe == nil { suggestionContainer.ReadinessProbe = &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{ - defaultGRPCHealthCheckProbe, - fmt.Sprintf("-addr=:%d", consts.DefaultSuggestionPort), - fmt.Sprintf("-service=%s", consts.DefaultGRPCService), - }, + GRPC: &corev1.GRPCAction{ + Port: consts.DefaultSuggestionPort, + Service: &consts.DefaultGRPCService, }, }, InitialDelaySeconds: defaultInitialDelaySeconds, @@ -225,12 +220,9 @@ func (g *General) desiredContainers(s *suggestionsv1beta1.Suggestion, if viper.GetBool(consts.ConfigEnableGRPCProbeInSuggestion) && suggestionContainer.LivenessProbe == nil { suggestionContainer.LivenessProbe = &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{ - defaultGRPCHealthCheckProbe, - fmt.Sprintf("-addr=:%d", consts.DefaultSuggestionPort), - fmt.Sprintf("-service=%s", consts.DefaultGRPCService), - }, + GRPC: &corev1.GRPCAction{ + Port: consts.DefaultSuggestionPort, + Service: &consts.DefaultGRPCService, }, }, // Ref https://srcco.de/posts/kubernetes-liveness-probes-are-dangerous.html diff --git a/pkg/controller.v1beta1/suggestion/composer/composer_test.go b/pkg/controller.v1beta1/suggestion/composer/composer_test.go index f560e6447dd..9de963030fb 100644 --- a/pkg/controller.v1beta1/suggestion/composer/composer_test.go +++ b/pkg/controller.v1beta1/suggestion/composer/composer_test.go @@ -817,12 +817,9 @@ func newFakeContainers() []corev1.Container { }, ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{ - defaultGRPCHealthCheckProbe, - fmt.Sprintf("-addr=:%d", consts.DefaultSuggestionPort), - fmt.Sprintf("-service=%s", consts.DefaultGRPCService), - }, + GRPC: &corev1.GRPCAction{ + Port: consts.DefaultSuggestionPort, + Service: &consts.DefaultGRPCService, }, }, InitialDelaySeconds: defaultInitialDelaySeconds, @@ -830,12 +827,9 @@ func newFakeContainers() []corev1.Container { }, LivenessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{ - defaultGRPCHealthCheckProbe, - fmt.Sprintf("-addr=:%d", consts.DefaultSuggestionPort), - fmt.Sprintf("-service=%s", consts.DefaultGRPCService), - }, + GRPC: &corev1.GRPCAction{ + Port: consts.DefaultSuggestionPort, + Service: &consts.DefaultGRPCService, }, }, InitialDelaySeconds: defaultInitialDelaySeconds,