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 devcontainers scaffolding for project generation #3432

Closed
kannon92 opened this issue May 25, 2023 · 19 comments
Closed

Add devcontainers scaffolding for project generation #3432

kannon92 opened this issue May 25, 2023 · 19 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@kannon92
Copy link

What do you want to happen?

Devcontainers/GitHub workspaces are becoming more popular ways of developing. Has there been any consideration on how to run a kube builder generates project as a devcontainer?

Extra Labels

/kind documentation

@kannon92 kannon92 added the kind/feature Categorizes issue or PR as related to a new feature. label May 25, 2023
@k8s-ci-robot k8s-ci-robot added the kind/documentation Categorizes issue or PR as related to documentation. label May 25, 2023
@camilamacedo86
Copy link
Member

Hi @kannon92,

Could you please give an example of what you are looking for?
Are you trying to create e2e tests where they would be executed in a devcontainer?

@camilamacedo86 camilamacedo86 added the triage/needs-information Indicates an issue needs more information in order to work on it. label Jun 14, 2023
@kannon92
Copy link
Author

Yea, basically I want to develop and test my operator with a GitHub workspace/devcontainers. Ideally run unit/integration.

So I was going to see if I could figure out how to make my kubebuilder project run in a devcontainer but I was running into some issues because I’m not as familiar with this as I should.

But I was thinking that if there was any consideration on the roadmap for a template for generating a devcontainer for new kubebuilder projects.

Does that make sense?

@camilamacedo86
Copy link
Member

camilamacedo86 commented Jul 3, 2023

Hi @kannon92,

It is an interesting request. To test the project you will need to:

  • Have k8s installed (it can be kind for example)
  • Then you will build the image, load the image, run make install and make deploy IMG=<imagename>

You can check the e2e tests done in : https://github.com/operator-framework/operator-sdk/blob/master/testdata/go/v4-alpha/monitoring/memcached-operator/test/e2e/e2e_test.go#L114-L133 to know better those steps.

If you would like to push a PR with the solution in place I think that would be acceptable.
In the worst scenario, If we see that would be much associated with an third-party we can either move with this code implementation for a plugin implementation where we could indeed scaffold other related helpers .

WDYT? Would you like to contribute with the project and propose a PR with this?

@camilamacedo86 camilamacedo86 removed the triage/needs-information Indicates an issue needs more information in order to work on it. label Jul 3, 2023
@Sajiyah-Salat
Copy link
Contributor

This I got from github docs as I was trying to understand the devcontainer or githubcode spaces. Acording to docs they are simple codespaces and different repository have different configuration where they add tools and things required for the the development of the specific project. Looks like we need to try to setup development configuration in codespaces of github. So it can be easy to develop things directly from github and no need of pulling the code to local.

@Sajiyah-Salat
Copy link
Contributor

I am interested in this pr but I would like to understand first to get to result.

@kannon92
Copy link
Author

Hi @kannon92,

It is an interesting request. To test the project you will need to:

  • Have k8s installed (it can be kind for example)
  • Then you will build the image, load the image, run make install and make deploy IMG=<imagename>

You can check the e2e tests done in : https://github.com/operator-framework/operator-sdk/blob/master/testdata/go/v4-alpha/monitoring/memcached-operator/test/e2e/e2e_test.go#L114-L133 to know better those steps.

If you would like to push a PR with the solution in place I think that would be acceptable. In the worst scenario, If we see that would be much associated with an third-party we can either move with this code implementation for a plugin implementation where we could indeed scaffold other related helpers .

WDYT? Would you like to contribute with the project and propose a PR with this?

Hey @camilamacedo86,

Not sure if I have the bandwidth. I noticed that there was an initiative to make Kubernetes build in a devcontainer (kubernetes/kubernetes#113019) and there seems to be a few issues in kind to set this up also.

Kind issue 1 (kubernetes-sigs/kind#2967) and kubernetes-sigs/kind#3196.

@camilamacedo86
Copy link
Member

Hi @kannon92,

I remember that I did a test in the past using devcontainers to check the project running in the github workspace. I used this configuration, see: https://github.com/camilamacedo86/kubebuilder/blob/workspace/.devcontainer/devcontainer.json

See that used minikube instead. However, if you be able to use kind that is better because it is possible to build and load the image without need to push it to a registry. I am not sure if with minikube it is possible to do the same.

Can you please check this one and see if that works for you?
If not, share the problems faced then we can try to help you out with.

@Sajiyah-Salat
Copy link
Contributor

Hello @kannon92 @camilamacedo86 I am just trying to help here. I have found a command through which we can build and load the image without pushing to registry in minikube.

eval $(minikube docker-env)
docker build -t my_image .
kubectl run my_image --image=my_image

eval $(minikube docker-env) :
it is a bash command that will export a set of environment variables that point your Docker CLI to the Docker daemon inside the Minikube

Let me know if it helps.

@awfuel
Copy link

awfuel commented Jul 17, 2023

Devcontainers are relatively very new and I went through the same (very frustrating) problem with kind that Kannon92 pointed out that it is so soon. That said there is an easier way to get started, you can use devpod https://devpod.sh/ to manage devcontainer workspaces and choose any backend provider you prefer (Docker and vscode integration to start is logical). One of many reasons to use devcontainer is so that it improves building isolation and removes any variations in developers local setup for building objects which should increase code quality long term. You can think of Devpod as similar to Podman or Toolbox (SIlverblue) or Codespaces but much more flexible as you can run and push your changes in git to source control anywhere. I intend to use it for an operator.

@camilamacedo86
Copy link
Member

Hi @awfuel,

It is nice to know that this third-party can help out. However, I think here the goal would to be to share a config without the usage of ANY third-part at all. See that we just need a config with KIND to achieve the goal or minikube and load the image locally: https://minikube.sigs.k8s.io/docs/handbook/pushing/#7-loading-directly-to-in-cluster-container-runtime

@FabianKramm
Copy link

FabianKramm commented Aug 8, 2023

@camilamacedo86 I created https://github.com/loft-sh/devpod-kubebuilder-template/blob/main/.devcontainer/devcontainer.json which is just a config that works for Github codespaces without any additional tools (solves the kind problem you mentioned).

DevPod is just an alternative tool (not an additional one) to Github codespaces (has the same config, also on the official website, see https://containers.dev/supporting#devpod), that allows you to run this configuration anywhere (including Kubernetes) and not just on Github hosted servers or the vscode devcontainer plugin.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2024
@camilamacedo86
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 26, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 25, 2024
@camilamacedo86
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 25, 2024
@camilamacedo86 camilamacedo86 added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. priority/backlog Higher priority than priority/awaiting-more-evidence. labels Jul 19, 2024
@camilamacedo86
Copy link
Member

Use kind or minikube probably is no longer an issue within right.
So, I think we could move forward with this one !

@TAM360
Copy link
Contributor

TAM360 commented Jul 23, 2024

@camilamacedo86 I am gonna work on this issue.

@TAM360
Copy link
Contributor

TAM360 commented Jul 23, 2024

/assign

@camilamacedo86
Copy link
Member

Done on master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

8 participants