4

I am a newbie for operator-sdk. Now I am writing test for operator with envtest framework, so I had a fake control-plane for environments.

Inside controller reconcile loop, once I initialize a CR, then controller will pull down an image for pod and deploy that Pod.

All behaviour in the above happens in the real k8s cluster. My question is, under envtest environemnts, does controller really pull down image for deploying Pods?

Grigoriy Mikhalkin
  • 5,035
  • 1
  • 18
  • 36
Joe
  • 623
  • 7
  • 16

1 Answers1

3

That depends on envtest configuration. Here is quotes from kubebuilder book:

[envtest] setting up and starting an instance of etcd and the Kubernetes API server, without kubelet, controller-manager or other components

Unless you’re using an existing cluster, keep in mind that no built-in controllers are running in the test context

So, if you don't set USE_EXISTING_CLUSTER env var to true, envtest will set control plane with only API server and etcd. For example, if your controller should create Deployment at some event, there's no deployment controller in test environment that gonna create ReplicaSet and Pods. Basically, all it does is stores state of test environment in etcd.

Grigoriy Mikhalkin
  • 5,035
  • 1
  • 18
  • 36
  • HI @Grigoriy Mikhalkin, in fake control plane, my contoller will create a Deployment. I want to know whether Deployment object could be created successfully even though there is no deployment controller in the envTest. Thanks – Joe Nov 10 '20 at 20:01
  • 1
    @Joe, there will be entry about Deployment object in etcd. But because deployment controller is missing there will be no Pods associated with it. So, answering your question "does controller really pull down image for deploying Pods" -- no, if your controller creates only Deployment, there will be no Pods in test cluster. – Grigoriy Mikhalkin Nov 10 '20 at 20:15
  • 1
    Thanks @Grigoriy Mikhalkin – Joe Nov 10 '20 at 21:04