1

I am trying to create a pod run a command edit an exist resource , but its not working My CR is

apiVersion: feature-toggle.resource.api.sap/v1
kind: TestCR
metadata:
  name: test
  namespace: my-namespace
spec:
  enabled: true
  strategies:
    - name: tesst
      parameters:
        perecetage: "10"

The command I am trying to run is

kubectl run kube-bitname --image=bitnami/kubectl:latest -n  my-namespace --command -- kubectl get testcr test -n my-namespace -o json | jq '.spec.strategies[0].parameters.perecetage="66"' | kubectl apply -f -

But This not work ? any idea ?

6
  • Can you add more context? I would like to understand why you need to let it run in a separate pod. Did you think about other options? Commented Sep 19, 2022 at 12:51
  • Can you just run that kubectl command locally, delete everything up through the --command -- options? Are you running the temporary pod with a ServiceAccount with RBAC permissions to read TestCR objects? When you say it doesn't work, what does happen? Commented Sep 19, 2022 at 13:19
  • @DavidMaze it works if I just run the kubectl without the kubectl run --command Commented Sep 19, 2022 at 13:23
  • @Manuel I have a cronJob scheduled every 2 days with create a job. The job will create the pod through this command for updating my custom CR Commented Sep 19, 2022 at 13:24
  • Did you check for other options? Commented Sep 19, 2022 at 14:17

1 Answer 1

2

It would be better if you post more info about the error o the trace that are you getting executing the command, but I have a question that could be a good insight about what is happening here.
Has the kubectl command that you are running inside the bitnami/kubectl:latest any context that allow it to connect to your cluster? If you take a look into the kubectl docker hub documentation you can see that you should map a config file to the pod in order to connect to your own cluster.

$ docker run --rm --name kubectl -v /path/to/your/kube/config:/.kube/config bitnami/kubectl:latest
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.