Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make wrapper server work with distroless-based images #3070

Merged
merged 1 commit into from
Apr 30, 2022

Conversation

mengqiy
Copy link
Contributor

@mengqiy mengqiy commented Apr 29, 2022

Creating this PR sooner to unblock other folks.
I will add an distroless-base KRM function in gcr.io/kpt-fn-demo and then add an e2e test for it.
Alternatively, we can use something like gcr.io/cad-demo-sdk/set-namespace:latest, but I'm not sure if gcr.io/cad-demo-sdk will be deleted later.
We can also consider mirroring an image from gcr.io/cad-demo-sdk to gcr.io/kpt-fn-demo for testing purpose only.

@bgrant0607
Copy link
Contributor

Thanks!

The code for those functions is pretty small (50-100 lines each). We could take one and add it to the demo functions as an example of a distroless function, or we could convert an existing function to distroless.

Example Dockerfile:

# Build the function
FROM golang:1.17 AS build
WORKDIR /go/ui
COPY go.mod .
COPY go.sum .
COPY ./clients/go ./clients/go
RUN CGOENABLED=0 go build -v k8s.io/klog/v2 sigs.k8s.io/kustomize/kyaml/yaml/...

COPY backend/pkg/yoy backend/pkg/yoy
COPY functions/validate-resourcequota/*.go functions/validate-resourcequota/
RUN CGOENABLED=0 go build -o /validate-resourcequota -v ./functions/validate-resourcequota

# The runtime image
FROM gcr.io/distroless/base-debian11:latest
COPY --from=build /validate-resourcequota /validate-resourcequota
ENTRYPOINT [ "/validate-resourcequota" ]

Comment on lines +151 to +152
kpt fn eval "${DESTINATION}" --image set-image:v0.1.0 --fn-config set-image-config.yaml
rm set-image-config.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can kpt accept function config on stdin?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. it doesn't. kpt fn eval does accept stdin but for entire resourcelist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most customization in create-deployment-blueprint.sh can be converted to a kpt pipeline.

Comment on lines +151 to +152
kpt fn eval "${DESTINATION}" --image set-image:v0.1.0 --fn-config set-image-config.yaml
rm set-image-config.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. it doesn't. kpt fn eval does accept stdin but for entire resourcelist.

@mengqiy
Copy link
Contributor Author

mengqiy commented Apr 30, 2022

I'm going to merge this PR and will add an e2e test in a follow-up PR.

@mengqiy mengqiy merged commit 236b74f into kptdev:main Apr 30, 2022
@mengqiy mengqiy deleted the fnrunnerdeploy branch April 30, 2022 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants