Skip to content

Commit 8f5adbc

Browse files
visheshtanksaleshivamerla
authored andcommitted
Replacing kubectl with crd-apply-tool
Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com>
1 parent 444256d commit 8f5adbc

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

deployments/container/Dockerfile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ COPY internal/ internal/
2121
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
2222
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
2323

24-
# Install curl
25-
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
24+
#Install Git
25+
RUN apt-get update && apt-get install -y git
2626

27-
# Install kubectl for must-gather and helm upgrades hooks
28-
RUN if [ "$TARGETARCH" = "x86_64" ]; then OS_ARCH="amd64"; elif [ "$TARGETARCH" = "aarch64" ]; then OS_ARCH="arm64"; else OS_ARCH="$TARGETARCH"; fi \
29-
&& curl -LO https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/${OS_ARCH}/kubectl \
30-
&& chmod +x ./kubectl
27+
WORKDIR /utils
28+
29+
#Clone the k8s-operator-libs repo
30+
RUN git clone https://github.com/NVIDIA/k8s-operator-libs.git
31+
32+
WORKDIR /utils/k8s-operator-libs
33+
34+
#Checkout the version of the k8s-operator-libs repo that is compatible with the current version of the NIM Operator
35+
RUN git checkout 7d667fbaa7ac8fb02196987eb65296856e2dd564
36+
37+
#Build the crd-apply-tool
38+
RUN go build -o crd-apply-tool cmd/apply-crds/main.go
3139

3240
# Use distroless as minimal base image to package the manager binary
3341
FROM nvcr.io/nvidia/distroless/go:v3.1.5
@@ -36,7 +44,7 @@ ARG VERSION="unknown"
3644

3745
WORKDIR /
3846
COPY --from=builder /workspace/manager .
39-
COPY --from=builder /workspace/kubectl /usr/local/bin/kubectl
47+
COPY --from=builder /utils/k8s-operator-libs/crd-apply-tool /usr/local/bin/crd-apply-tool
4048

4149
# Add CRD resource into the image for helm upgrades
4250
COPY deployments/helm/k8s-nim-operator/crds/ /opt/nim-operator/crds/

deployments/helm/k8s-nim-operator/templates/upgrade_crd.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ spec:
9191
capabilities:
9292
drop:
9393
- ALL
94-
command: ["kubectl"]
94+
command: ["crd-apply-tool"]
9595
args:
96-
- "apply"
97-
- "-f"
98-
- "/opt/nim-operator/crds/*.yaml"
96+
- "--crds-dir=/opt/nim-operator/crds/"
9997
restartPolicy: OnFailure
10098
{{- end }}

0 commit comments

Comments
 (0)