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

Add k3d dev container #1

Merged
merged 10 commits into from
May 18, 2022
Merged

Add k3d dev container #1

merged 10 commits into from
May 18, 2022

Conversation

kforeverisback
Copy link
Owner

@kforeverisback kforeverisback commented May 17, 2022

Description

Add a new devcontainer definition for k3d kubernetes cluster.

With this, user will be able to create a new devcontainer which will enable the creation of a local kubernetes cluster (automated or manual).

This PR is based off of kubernetes-helm-minikube dev container.

PR Checklist

  • I have updated the documentation accordingly.
    • Added README.md describing the container
    • Added sample nginx deployment document in README.md
  • I have added/updated tests to cover my changes.
    • Changed test.sh under test-project directory
  • All new and existing tests passed.
  • My code follows the code style of this project.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • Lint checker not integrated but fixed most Markdown lint errors (followed existing container document format)

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • Manually created Codespaces from .devcontainer
    • Provisioned a k3d cluster from terminal
    • Automatically provisioned k3d cluster in postStartCommand
  • Manually created local devcontainer
    • Provisioned a k3d cluster from terminal afterwards
    • Automatically provisioned k3d cluster in postStartCommand
  • Manually applied pods/deployments to verify k3d cluster

References

@kforeverisback kforeverisback added the enhancement New feature or request label May 17, 2022
@kforeverisback kforeverisback requested review from iamnicoj and sivamu May 17, 2022 23:10
@kforeverisback kforeverisback self-assigned this May 17, 2022
@kforeverisback kforeverisback requested a review from juzuluag May 17, 2022 23:19
Copy link

@juzuluag juzuluag left a comment

Choose a reason for hiding this comment

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

Overall lgtm, just one comment to address. Maybe something to look in other definitions to see how it is done.

RUN apt-get update && /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
&& /bin/bash /tmp/library-scripts/docker-in-docker-debian.sh "true" "${USERNAME}" "${USE_MOBY}" \
&& /bin/bash /tmp/library-scripts/kubectl-helm-debian.sh "latest" "latest" "latest" \
&& mkdir -p /home/${USERNAME}/.k3d \

Choose a reason for hiding this comment

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

I'm not 100% that /home should be hardcoded here. It might be that the user's home dir not to be at /home. I think it can be configurable on devcontainer.json

Copy link
Owner Author

Choose a reason for hiding this comment

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

We followed the same pattern used by kubernetes-helm-minikube.
But using $HOME is better since, it should be set per-user with useradd or usermod command.

"runArgs": ["--privileged"],
"mounts": [
"source=k3d-var-lib-docker,target=/var/lib/docker,type=volume",
"source=k3d-config,target=/home/vscode/.k3d,type=volume",

Choose a reason for hiding this comment

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

Same comment here with regards /home/vscode

Copy link
Collaborator

@iamnicoj iamnicoj May 18, 2022

Choose a reason for hiding this comment

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

maybe we can use something like "~" or "$USER "?

Copy link
Owner Author

Choose a reason for hiding this comment

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

We can use ${containerEnv:HOME} to represent HOME directory inside the container.
Reference: https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_variables-in-devcontainerjson

Copy link
Owner Author

Choose a reason for hiding this comment

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

containerEnv:HOME/.k3d doesn't work.
But /home/${remoteUser}/.k3d works fine.

Copy link

@juzuluag juzuluag left a comment

Choose a reason for hiding this comment

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

👍

@kforeverisback kforeverisback merged commit 8460738 into main May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants