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

kind clusters: replace docker-cli commands with Docker Engine Go Client to improve podman compatibility #540

Merged

Conversation

chzar
Copy link
Contributor

@chzar chzar commented Sep 18, 2024

Changes

Replaced the docker-cli commands in kind.go with github.com/docker/docker/client

/kind enhancement

Fixes #408
Fixes #528

Release Note

Improves cross compatibility between users of docker and podman (if docker compatibility mode is enabled). Removes the requirement of installing docker-cli for podman users.

Docs

Podman users should be instructed to enable Docker compatibility mode

Copy link

linux-foundation-easycla bot commented Sep 18, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

knative-prow bot commented Sep 18, 2024

Welcome @chzar! It looks like this is your first PR to knative-extensions/kn-plugin-quickstart 🎉

Copy link

knative-prow bot commented Sep 18, 2024

Hi @chzar. Thanks for your PR.

I'm waiting for a knative-extensions member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 18, 2024
@chzar chzar force-pushed the feat/kind-use-docker-client-go branch 2 times, most recently from f4f1a30 to 0bdaaf1 Compare September 18, 2024 12:45
@chzar chzar force-pushed the feat/kind-use-docker-client-go branch from 0bdaaf1 to 9f08901 Compare September 18, 2024 12:50
@chzar chzar changed the title kind clusters: replace docker-cli commands with Docker Engine Go Client to improve podman compatiblity kind clusters: replace docker-cli commands with Docker Engine Go Client to improve podman compatibility Sep 18, 2024
@psschwei
Copy link
Contributor

Thanks for the PR! You'll need to sign the CLA before we can merge this.
/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 18, 2024
@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 18, 2024
@chzar
Copy link
Contributor Author

chzar commented Sep 18, 2024

Thanks for the PR! You'll need to sign the CLA before we can merge this. /ok-to-test

Signed, sealed, delivered.

@psschwei
Copy link
Contributor

When trying this with podman, I got the following error:

Command Output: Error: rootlessport cannot expose privileged port 80, you can add 'net.ipv4.ip_unprivileged_port_start=80' to /etc/sysctl.conf (currently 1024), or choose a larger port number (>= 1024): listen tcp 0.0.0.0:80: bind: permission denied

I don't use podman on a regular basis, so not sure if regular podman users would already have a workaround for the port issue or if we should think about changing the host port on the cluster...

With docker, everything worked fine.

@chzar
Copy link
Contributor Author

chzar commented Sep 20, 2024

I am on macOS and using podman machine so kind works out of the box.

Perhaps changing to port 8080 or 9000 would be more appropriate for a test/demo setup?

@psschwei
Copy link
Contributor

Perhaps changing to port 8080 or 9000 would be more appropriate for a test/demo setup?

Yeah, I think that makes sense... would you want to do that change too?

@chzar
Copy link
Contributor Author

chzar commented Sep 20, 2024

Sure. I can make a separate PR.

This change should work for all MacOS/Windows users of docker/podman. For Linux users, the restrictions on binding Port 80 have always been present for both docker and podman - so nothing is broken that wasn't so before.

func deleteContainerRegistry() *exec.Cmd {
return exec.Command("docker", "rm", "-f", container_reg_name, "&&", "||", "true")
func deleteContainerRegistry(dcli *dclient.Client) error {
if err := dcli.ContainerRemove(context.Background(), container_reg_name, container.RemoveOptions{Force: true}); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to check if a registry container is running first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would it matter if the container was running or stopped?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, shouldn't have used the word "running" in my original comment... the issue isn't whether the registry container is running or stopped but rather if it exists or not.

Because the deleteContainerRegistry() method now returns an error, the whole quickstart will fail if the registry container doesn't exist.

$ ./kn-quickstart kind --registry
Running Knative Quickstart using Kind
✅ Checking dependencies...
    Kind version is: 0.23.0
💽 Installing local registry...
Pulling from library/registry: 2
Digest: sha256:ac0192b549007e22998eb74e8d8488dcfe70f1489520c3b144a6047ac5efbe90: %!s(<nil>)
Status: Image is up to date for registry:2: %!s(<nil>)
Error: creating cluster: failed to delete local registry: failed remove registry container: Error response from daemon: No such container: kind-registry

whereas before quickstart wouldn't fail when trying to delete a non-existent registry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I follow you. I will improve the error handling such that it does not return an error in this case instead of trying to check for the existence of the registry prior to deletion. It's possible that the registry container is deleted by another client prior to my delete container api call.

Copy link
Contributor

@psschwei psschwei left a comment

Choose a reason for hiding this comment

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

Thanks!
/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2024
Copy link

knative-prow bot commented Sep 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chzar, psschwei

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 30, 2024
@knative-prow knative-prow bot merged commit 25876b3 into knative-extensions:main Sep 30, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

containerd deprecated CRI hosts config kn quickstart kind - Error: creating cluster: docker not running
2 participants