wael mashal
wael mashal

Reputation: 29

Edit kubernetes resource using kubectl run --command

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 ?

Upvotes: 1

Views: 306

Answers (1)

mauricubo
mauricubo

Reputation: 331

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

Upvotes: 2

Related Questions