redhat-scholars/kubernetes-tutorial

Operators Tutorial - Pizza Operator GET request to Kubernetes API fails

Opened this issue · 0 comments

a37tam commented

Reproduction Steps

I followed these steps in the Operators tutorial:

kubectl create namespace pizzahat
kubectl config set-context --current --namespace=pizzahat

kubectl apply -f apps/pizzas/pizza-crd.yaml
kubectl apply -f apps/pizzas/pizza-deployment.yaml

Output of kubectl get pods -n pizzahat
image

Output of kubectl describe pod
image

To get more information, I tailed the pod.

Output of stern -n pizzahat pod/quarkus-operator-example-...
image

Investigation

I believe the URL is incorrect. More specifically, the authorization header should be included (or fixed somewhere in the Pizza Operator code), and v1beta1 should be v1.

Here are my steps for arriving at that conclusion:

  • Slightly modify apps/pizzas/pizza-deployment. I override the container's entrypoint so that I can get a shell:
    image

  • From inside the container, I curl the Kubernetes API.

    I executed the following commands:

    KUBE_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
    curl -sSk -H "Authorization: Bearer $KUBE_TOKEN" https://10.152.183.1:443/apis/apiextensions.k8s.io/v1/customresourcedefinitions

    This works.