cilium-cli icon indicating copy to clipboard operation
cilium-cli copied to clipboard

Convenient way to persistently set cilium namespace

Open rptaylor opened this issue 10 months ago • 6 comments

Proposal / RFE

Is your feature request related to a problem?

It is inconvenient and distracting to have to remember to add -n cilium when typing every command, especially when copy/pasting from documentation for example.

Describe the solution you'd like There should be an easy way to persistently configure the namespace of the cilium installation in your environment. For example an env var like CILIUM_NAMESPACE or a ~/.cilium/config file or something. That way you can just set it once and not worry about having to type it every time.

rptaylor avatar Feb 05 '25 00:02 rptaylor

Continuation of https://github.com/cilium/cilium-cli/issues/2067

rptaylor avatar Feb 05 '25 00:02 rptaylor

$ cilium status
    /¯¯\
 /¯¯\__/¯¯\    Cilium:             1 errors
 \__/¯¯\__/    Operator:           disabled
 /¯¯\__/¯¯\    Envoy DaemonSet:    disabled (using embedded mode)
 \__/¯¯\__/    Hubble Relay:       disabled
    \__/       ClusterMesh:        disabled

Containers:            cilium             
                       cilium-operator    
Cluster Pods:          25/25 managed by Cilium
Helm chart version:    
Errors:                cilium    cilium    daemonsets.apps "cilium" not found
status check failed: [daemonsets.apps "cilium" not found, unable to retrieve ConfigMap "cilium-config": configmaps "cilium-config" not found]
$ cilium -n cilium status
    /¯¯\
 /¯¯\__/¯¯\    Cilium:             OK
 \__/¯¯\__/    Operator:           OK
 /¯¯\__/¯¯\    Envoy DaemonSet:    OK
 \__/¯¯\__/    Hubble Relay:       disabled
    \__/       ClusterMesh:        disabled

DaemonSet              cilium             Desired: 6, Ready: 6/6, Available: 6/6
DaemonSet              cilium-envoy       Desired: 6, Ready: 6/6, Available: 6/6
Deployment             cilium-operator    Desired: 2, Ready: 2/2, Available: 2/2
Containers:            cilium             Running: 6
                       cilium-envoy       Running: 6
                       cilium-operator    Running: 2
Cluster Pods:          25/25 managed by Cilium
Helm chart version:    1.16.6
Image versions         cilium             quay.io/cilium/cilium:v1.16.6@sha256:1e0896b1c4c188b4812c7e0bed7ec3f5631388ca88325c1391a0ef9172c448da: 6
                       cilium-envoy       quay.io/cilium/cilium-envoy:v1.30.9-1737073743-40a016d11c0d863b772961ed0168eea6fe6b10a5@sha256:a69dfe0e54b24b0ff747385c8feeae0612cfbcae97bfcc8ee42a773bb3f69c88: 6
                       cilium-operator    quay.io/cilium/operator-generic:v1.16.6@sha256:13d32071d5a52c069fb7c35959a56009c6914439adc73e99e098917646d154fc: 2

rptaylor avatar Feb 05 '25 01:02 rptaylor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Apr 06 '25 02:04 github-actions[bot]

Surprised this isn't supported yet.

rptaylor avatar Apr 16 '25 19:04 rptaylor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Jun 16 '25 02:06 github-actions[bot]

Still relevant.

rptaylor avatar Jun 16 '25 18:06 rptaylor

@rptaylor can i work on this?

saqlainnnnn avatar Jul 08 '25 16:07 saqlainnnnn

@saqlainnnnn Feel free, that would be great! An env var like CILIUM_NAMESPACE seems simplest to me.

rptaylor avatar Jul 08 '25 17:07 rptaylor

Hi there, new to the Cilium project. Can I help with this? Thanks

td0ne avatar Aug 29 '25 05:08 td0ne

Hi there, new to the Cilium project. Can I help with this? Thanks

Feel free!

rptaylor avatar Aug 29 '25 17:08 rptaylor

Hello, I created a PR that I believe encompasses the required changes. I am fairly new to this project, and didn't see how to assign the issue to me specifically. Thank you, I welcome any and all critic and review.

td0ne avatar Sep 07 '25 00:09 td0ne

Hello, I created a PR that I believe encompasses the required changes. I am fairly new to this project, and didn't see how to assign the issue to me specifically. Thank you, I welcome any and all critic and review.

Nice. Maybe set it to non-draft if it is ready for review, hopefully someone will look at it.

rptaylor avatar Sep 08 '25 17:09 rptaylor

After review the PR was closed. Unless my understanding was completely wrong, I believe that the changes encompassed what was requested without removing functionality. Could someone clarify:

  • Did I misunderstand the functionality requirements for this issue?
  • From the contributing README in this repository I believed these issues were in scope for the main repository, is this not true?

Thank you

td0ne avatar Sep 17 '25 21:09 td0ne

This issue has been open for several months, hoping/waiting for a developer or maintainer to comment with a suggestion, yes/no, implementation notes, or any other discussion or guidance that would be required to move forward (or not). Gathering feedback in an issue in advance can help avoid contributors becoming frustrated and discouraged from volunteering their time to contribute an improvement without knowing how it will be received. (Bless your heart @td0ne for trying! )

Maybe it was a case of just misreading the PR? https://github.com/cilium/cilium/pull/41557#pullrequestreview-3229379481

Removing flags and replacing them with environment variables

If I understand correctly the flag was not removed, the PR only adds an environment variable, and the -n flag still takes precedence over the environment variable (but I don't know Go so I'm not sure of the code).

This is a very simple way to reduce friction for the user experience, and installing everything into kube-system by default is not best practice security-wise, so this seems like a no-brainer to me ....

@asauber do you have any feedback? Thanks.

rptaylor avatar Sep 17 '25 22:09 rptaylor

I suppose an alternative approach could be for the cilium CLI to do something like helm list -A and try to detect where the cilium chart is installed, but an env var seems foolproof and much simpler, and is a pretty common standard pattern for CLIs to follow; I honestly can't think of any downside to it.

rptaylor avatar Sep 17 '25 22:09 rptaylor

Hi all, my apologies, I did misread the original diff. I have dropped an approval with a suggestion for changes to the description to match the surrounding descriptions.

Thank you @td0ne for the contribution. Would you be able to make that change and rebase the PR?

asauber avatar Sep 18 '25 06:09 asauber

Thanks @asauber , appreciate you checking this out!

I have amended my commit and re-based with main. Thanks for the feedback! I could have provided a more detailed description of the PR, sorry for the confusion.

td0ne avatar Sep 18 '25 20:09 td0ne