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

Better local deployment workflow #142

Closed
2 tasks done
fanminshi opened this issue Mar 28, 2018 · 9 comments
Closed
2 tasks done

Better local deployment workflow #142

fanminshi opened this issue Mar 28, 2018 · 9 comments

Comments

@fanminshi
Copy link
Contributor

fanminshi commented Mar 28, 2018

Currently, the the deployment workflow of an operator is:

  • Build the image: operator-sdk build $Image
  • Push the image to a public registry: docker push $Image
  • Create the operator deployment: kubectl create -f deploy/operator.yaml
  • Then test out the operator image via kubectl

Development cycle can be faster if we can avoid building/pushing the image. A workflow like the following maybe better (idea learned from kubebuilder):

  • Build the operator binary bin/operator that knows kubeconfig so that the client can access the kubernetes cluster that's associated with kubeconfig.
  • Execute ./bin/operator
  • Then test out the operator via kubectl

The proposed approach saves developer time from building and pushing Image to a registry and operator deployment.

Action Items:

@fanminshi
Copy link
Contributor Author

cc/ @philips If you can take a look of this, it will be great. I think you have proposed this idea earlier as well.

@fanminshi fanminshi changed the title Better Local Testing Better local deployment workflow Mar 29, 2018
@philips
Copy link

philips commented Mar 30, 2018

Yes! I think the model outlined in kubebuilder is similar and it is certainly faster! :)

@fanminshi
Copy link
Contributor Author

fanminshi commented May 3, 2018

I am proposing to have a operator-sdk up or something better named to help user to achieve the better local workflow.

Instead of the users follow the operator-sdk build $Image and docker push $Image model every time they need to test out their code locally, the users can just call operator-sdk up --kubeconfig=<your-kubeconfig-path> to run the operator locally.

The operator-sdk up compiles and runs the operator binary and gives it's internal Kubernete client the access to a kubernetes cluster by setting the client config to that of the passed in --kubeconfig.
In this way, you can think that your local machine is a "pod" of a Kubernete cluster, and it can watch, query, and mutate anything in that Kubernete cluster.

@spahl
Copy link
Contributor

spahl commented May 3, 2018

That is quite useful indeed.

There are two ways of bringing something up for dev and test. One local (for rapid iteration) one where the operator gets builts, pushed to the registry and started in the remote cluster (for ci testing for example or developing on the actual container image and testing that).

IMHO It would be good for the "up" command to allow both. Something like "up" for remote and "up --local" for the local dev workflow.

@fanminshi
Copy link
Contributor Author

IMHO It would be good for the "up" command to allow both. Something like "up" for remote and "up --local" for the local dev workflow.

I am thinking about having separate sub commands for local and cluster deployment.
like up local [args] [flags] and up cluster [args] [flags] or r/up/deploy/ for better naming.

The reason for having separate command is that I suspect that up cluster might have a total of different flags and args than that of up local. If we combine the up cluster and the up local into one command, I suspect most of the flags won't be apply to both and also may cause confusion to users.

@spahl
Copy link
Contributor

spahl commented May 3, 2018

Yeah you are right the subcommands are good and more explicit than flags.

@Verolop
Copy link

Verolop commented May 3, 2018

I agree with having separate commands, since the definitions and use cases don't necessarily overlap

@fanminshi
Copy link
Contributor Author

operator-sdk up local command is implemented via #219

I'll add doc to describe how to use it on the next few days.

@kgibm
Copy link
Contributor

kgibm commented Aug 25, 2021

Hi, what's the latest recommended approach to this? I see operator-sdk up was removed and I can't find the alternative. I tried make build docker-build install deploy but the pod shows as ErrImagePull and make run shows if kind is a CRD, it should be installed before calling Start.

Note that the non-local flow of pushing and pulling from DockerHub works with make docker-build docker-push IMG="..." and make deploy IMG="..."

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

No branches or pull requests

5 participants