How to test operator - cniackz/public GitHub Wiki

Related:

How we tested Operator v5.0.1:

  • Directory:
/Users/cniackz/operator/cmd/operator
  • Output directory:
/Users/cniackz/operator
  • Working directory:
/Users/cniackz/operator
  • Environment:
CGO_ENABLED=0;GOOS=darwin;GOARCH=arm64
  • Go tool arguments:
-trimpath

If you use --trimpath breakpoints will not work!!!

  • Program arguments:
controller --kubeconfig=/Users/cniackz/.kube/config
  • Intro: We compiled in IntelliJ and used breakpoints, it worked but we had to change the code a bit since --kubeconfig=/Users/cniackz/.kube/config was not working as before, plus Directory was changed as explained by Pedro where the entry point changed as well, so here the details:
  • on a terminal, kubectl proxy

  • on file pkg/controller/controller.go line: 82 replace cfg, err := rest.InClusterConfig() for:

var err error
	cfg := &rest.Config{
		Host:            "http://localhost:8001/",
		TLSClientConfig: rest.TLSClientConfig{Insecure: true},
		APIPath:         "/",
		BearerToken:     "eyJhbGciOiJSUzI1NiIsImtpZCI6InFETTJ6R21jMS1NRVpTOER0SnUwdVg1Q05XeDZLV2NKVTdMUnlsZWtUa28ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRldi1zYS10b2tlbi14eGxuaiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJkZXYtc2EiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJmZDVhMzRjNy0wZTkwLTQxNTctYmY0Zi02Yjg4MzIwYWIzMDgiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6ZGVmYXVsdDpkZXYtc2EifQ.woZ6Bmkkw-BMV-_UX0Y-S_Lkb6H9zqKZX2aNhyy7valbYIZfIzrDqJYWV9q2SwCP20jBfdsDS40nDcMnHJPE5jZHkTajAV6eAnoq4EspRqORtLGFnVV-JR-okxtvhhQpsw5MdZacJk36ED6Hg8If5uTOF7VF5r70dP7WYBMFiZ3HSlJBnbu7QoTKFmbJ1MafsTQ2RBA37IJPkqi3OHvPadTux6UdMI8LlY7bLkZkaryYR36kwIzSqsYgsnefmm4eZkZzpCeyS9scm9lPjeyQTyCAhftlxfw8m_fsV0EDhmybZCjgJi4R49leJYkHdpnCSkubj87kJAbGMwvLhMhFFQ",
	}
 flag.StringVar(&kubeconfig, "kubeconfig", "", "path to a kubeconfig. Only required if out-of-cluster")

Note:

Still you can compile, push the container to the registry and test directly over a cluster for final testing.

After your fix, you can pass the flag:

Testing final solution in the cluster by building:

make build

Get the container name

 => => naming to docker.io/minio/operator:v5.0.5-5-g4eb4d3c4   
createcluster
installoperator
kind load docker-image docker.io/minio/operator:v5.0.5-5-g4eb4d3c4
apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - name: minio-operator
          image: docker.io/minio/operator:v5.0.5-5-g4eb4d3c4

How to connect local Operator with Tenant pods

  1. create cluster with nginx as in https://github.com/cniackz/public/wiki/MinIO-Ingress-on-Kind-for-testing-and-learning or in https://github.com/minio/wiki/wiki/MinIO-Ingress-on-Kind-for-testing-and-learning

  2. installoperator with nginx

  3. have 0 replicas en minio operator deployment so you test your local code of operator

  4. remember to k proxy to contact k8s api

  5. trus the certs by opening minio service in browser and export the cert then trus the cert in keychain on mac:

  • /etc/hosts
127.0.0.1 minio.tenant-lite.svc.cluster.local

To communicate with a pod from your local operator.

k port-forward myminio-pool-1-0 9000 -n tenant-lite <--------------------------- To communicate with a pod from your local operator.