How to test Operator UI - cniackz/public GitHub Wiki

1. Prepare the cluster

kind delete cluster
kind create cluster --config ~/operator/testing/kind-config.yaml
kubectl apply -k ~/operator/resources
kubectl apply -k ~/operator/examples/kustomization/tenant-lite
kubectl apply -k ~/operator/examples/kustomization/tenant-kes-encryption

2. Do the proxy

k proxy  

3. Compile and run for operator

binary:
	@CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -trimpath --ldflags $(LDFLAGS) -o minio-operator ./cmd/operator
cd ~/operator
make binary
./minio-operator ui

4. Get the UI 5005 ready to get the curl (Don't use node version 18, 17, or below is ok...)

cd ~/operator/web-app
yarn install
yarn build
yarn run start

5. Get the token to login in the UI

# OLD WAY
SA_TOKEN=$(kubectl -n minio-operator  get secret $(kubectl -n minio-operator get serviceaccount console-sa -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode)
echo $SA_TOKEN

# NEW WAY
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: console-sa-secret
  namespace: minio-operator
  annotations:
    kubernetes.io/service-account.name: console-sa
type: kubernetes.io/service-account-token
EOF


SA_TOKEN=$(kubectl -n minio-operator  get secret console-sa-secret -o jsonpath="{.data.token}" | base64 --decode)
echo $SA_TOKEN

6. Go to the UI

http://localhost:5005/login

7. Get curl command from Developer tools

cniackz:/Users/cniackz # curl 'http://localhost:5005/api/v1/namespaces/tenant-tiny/tenants/storage-tiny/pvcs/data0-storage-tiny-pool-0-0/events' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7' \
  -H 'Connection: keep-alive' \
  -H 'Cookie: token=AbEB1NKSfo2xdzkMGVzKPVhGSHb4fPpZkNgPcER7R+pMM3PK7NjLwLEd066Cr7TlJDPpkL3ugDSCTl8iwXmwu3zAiWZ5nA3mz//WlL2HQeovow0kHDHiFSHzDiOY1fNmThS4krkcOlnxpN9od5u0aqONK15Lcf6vKlS1ZxAv/NsIQllSzjqdnw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3xFSmvgk/s1GAvyYqG1tFiWuGbw1aPMGnMZkXGxgoe4fgJuaOK41lH4HJ9NUyWOE1ai+vdJu+nYwH/LDr5Hf+T1uV7zA4GlH1w==' \
  -H 'Referer: http://localhost:5005/namespaces/tenant-tiny/tenants/storage-tiny/pvcs/data0-storage-tiny-pool-0-0' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' \
  -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --compressed
[{"event_type":"Normal","last_seen":1650903407,"message":"waiting for first consumer to be created before binding","namespace":"tenant-tiny","reason":"WaitForFirstConsumer"},{"event_type":"Normal","last_seen":1650903407,"message":"waiting for a volume to be created, either by external provisioner \"rancher.io/local-path\" or manually created by system administrator","namespace":"tenant-tiny","reason":"ExternalProvisioning"},{"event_type":"Normal","last_seen":1650903407,"message":"External provisioner is provisioning volume for claim \"tenant-tiny/data0-storage-tiny-pool-0-0\"","namespace":"tenant-tiny","reason":"Provisioning"},{"event_type":"Normal","last_seen":1650903411,"message":"Successfully provisioned volume pvc-f56b6475-fbe2-4255-bf96-e275f5cc0959","namespace":"tenant-tiny","reason":"ProvisioningSucceeded"}]

8. Modify the API code:

9. Recompile again:

sudo rm -rf ~/go
cd ~/console
make install
~/go/bin/console operator

10. Login again in the UI and get the new curl

[
  {
    "event_type": "Normal",
    "last_seen": 1650905114,
    "message": "waiting for first consumer to be created before binding",
    "namespace": "Cesar Celis Hernandez", <---------------------------------- You will see the modification now.
    "reason": "WaitForFirstConsumer"
  }
]

NOTE: If you see "zsh: killed"

sudo rm -rf ~/go