{"id":30318593,"url":"https://github.com/clubanderson/labeler","last_synced_at":"2025-08-17T20:12:52.570Z","repository":{"id":229895635,"uuid":"777877507","full_name":"clubanderson/labeler","owner":"clubanderson","description":"label ALL kubectl, kustomize, and helm objects, inline, without extra steps.(including namespaces and CRDs)","archived":false,"fork":false,"pushed_at":"2024-04-22T19:08:47.000Z","size":163603,"stargazers_count":14,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-19T12:23:51.150Z","etag":null,"topics":["helm","kubectl","kubernetes","kustomize"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clubanderson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-26T17:07:43.000Z","updated_at":"2024-04-26T19:05:43.000Z","dependencies_parsed_at":"2024-04-22T20:29:32.072Z","dependency_job_id":"7919a5ef-cda4-4154-a83a-d1ffd108e90b","html_url":"https://github.com/clubanderson/labeler","commit_stats":null,"previous_names":["clubanderson/hackathon-labeler","clubanderson/labeler"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/clubanderson/labeler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clubanderson%2Flabeler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clubanderson%2Flabeler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clubanderson%2Flabeler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clubanderson%2Flabeler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clubanderson","download_url":"https://codeload.github.com/clubanderson/labeler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clubanderson%2Flabeler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270899582,"owners_count":24664720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["helm","kubectl","kubernetes","kustomize"],"created_at":"2025-08-17T20:12:50.075Z","updated_at":"2025-08-17T20:12:52.551Z","avatar_url":"https://github.com/clubanderson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes Labeler\n\u003cimg src=\"media/kube-labeler.jpg\" alt=\"drawing\" width=\"100\"/\u003e \n\n## A labeler for all kubectl, kustomize, and helm resources  \n\n\u003c!-- [![Watch the video](https://youtu.be/lHcn3W7iuqA)](https://youtu.be/lHcn3W7iuqA) --\u003e\n\u003cimg src=\"media/labeler.gif\" width=\"800\"\u003e\n\n\n[Video Demo](https://youtu.be/lHcn3W7iuqA)\n\n\n**Challenge**: When working with Kubernetes objects it is necessary to find objects that are part of the same collection. Labels and annotations are a good way to flag objects so that they can be operated on as a collection. For instance, for an nginx package it would be useful to label the deployment, service, service account, and configmap that comes along with it. You could simply just use a namespace as a collection identifier. But a namespace will not help you identify cluster-scoped objects (which includes a namespace where the deployment, service, service account, and configmap reside) as part of a collection.\n\nCommon labels are used by Helm to identify objects that are part of the same collection. Most commonly used is:\n    \n    app.kubernetes.io/part-of: \u003cyour collection name here\u003e\n\nYou set a label with:\n  \n  For kubectl\n    \n    kubectl label \u003cobject-type\u003e \u003cobject-name\u003e \u003clabel-key\u003e=\u003clabel-value\u003e\n\n  For Helm\n    \n    helm install my-release my-chart --set labels.\u003clabel-key\u003e=\u003clabel-value\u003e\n\nYou can then use kubectl to get all items that contain the label you specified\n    \n    kubectl get all --selector=app.kubernetes.io/part-of=nginx\n\nYou would be quick to point out that helm and kubectl all have a means of labeling objects during installation/create/apply. This is partly true, if a) the project offers a well-formed, best-practices helm chart, b) if you do not use 'kubectl apply -f', and c) if you do not use 'kubectl -k' (kustomize) to install the application\n\nYes, for kubectl you can add labels to your source before applying with 'kubectl apply -f'. Yes, you can do the same for your helm source. And, yes, you can add labels to your kustomize object source files before applying with 'kubectl -k'. This is time-consuming work and requires you clone the source and manipulate it locally and possibly source control it for others to use. Imagine having to do this many times for different project source files. I am a platform engineer, and I can tell you that this is a tedious process. All it takes is a single upstream change/update and you need to read, edit, and store your version of the source files again.\n\nAfter hacking at this for some time, I decided to come up with 2 approaches to resolve this:\n\n(check out tests/test.sh for a full battery of tests)\n\n# Install with brew, or clone and build\n```\n    brew tap clubanderson/labeler https://github.com/clubanderson/labeler\n    brew update\n    brew install labeler\n``` \n  - or -\n```\n    git clone https://github.com/clubanderson/labeler\n    cd labeler\n    make build\n    make install\n```\n  - then -\n```\n    alias k=\"labeler kubectl\"\n    alias h=\"labeler helm\"\n```\n  - optional - edit your rc file (./zshrc) (or just run these commands on your local shell)\n\n# 1 - Labeler as an alias to kubectl and helm\n\nrun k as you would an kubectl command with arguments, and labeler will label all applied/created resources, or give output on how to do so:\n\n  kubectl\n\n    k apply -f examples/kubectl/pass -l app.kubernetes.io/part-of=sample --context=kind-kind --namespace=default --overwrite\n    \n    deployment.apps/my-app-deployment2 unchanged\n    service/my-app-service2 unchanged\n\n  kustomize\n\n  kustomize with \"\" or \"default\" namespace (object were previously created and labeled)\n\n    k apply -k examples/kustomize -l app.kubernetes.io/part-of=sample-app --context=kind-kind --namespace=default --overwrite\n      service/my-app-service already has label app.kubernetes.io/part-of=sample-app\n      deployment.apps/my-app-deployment already has label app.kubernetes.io/part-of=sample-app\n\n  kustomize with \"\" or \"default\" namespace (object were previously created and but new label value provided)\n\n    k apply -k examples/kustomize -l app.kubernetes.io/part-of=sample --context=kind-kind --namespace=default --overwrite \n      🏷️ created and labeled object \"my-app-service\" in namespace \"default\" with app.kubernetes.io/part-of=sample\n      🏷️ created and labeled object \"my-app-deployment\" in namespace \"default\" with app.kubernetes.io/part-of=sample\n\n  kustomize with a namespace other than \"\" or \"default\" (objects were previously created and labeled)\n\n    k apply -k examples/kustomize -l app.kubernetes.io/part-of=sample-app --context=kind-kind --namespace=temp --overwrite\n      service/my-app-service already has label app.kubernetes.io/part-of=sample-app\n      deployment.apps/my-app-deployment already has label app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/namespaces \"temp\" with app.kubernetes.io/part-of=sample-app\n\n  kustomize with a namespace other than \"\" or \"default\" (objects were previously created but new label value provided)\n\n    k apply -k examples/kustomize -l app.kubernetes.io/part-of=sample --context=kind-kind --namespace=temp --overwrite\n      🏷️ created and labeled object \"my-app-service\" in namespace \"temp\" with app.kubernetes.io/part-of=sample\n      🏷️ created and labeled object \"my-app-deployment\" in namespace \"temp\" with app.kubernetes.io/part-of=sample\n      🏷️ labeled object /v1/namespaces \"temp\" with app.kubernetes.io/part-of=sample\n\n  run h with any helm command line arguments, and labeler will label all installed resources, or give output on how to do so\n\n  helm (template)\n\n    h --kube-context=kind-kind template sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --label=app.kubernetes.io/part-of=sample-app --dry-run; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n      🏷️ labeled object /v1/namespaces \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n\n      The following resources do not exist and can be labeled at a later time:\n\n      kubectl label serviceaccounts sealed-secrets app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label clusterroles secrets-unsealer app.kubernetes.io/part-of=sample-app\n      kubectl label clusterrolebindings sealed-secrets app.kubernetes.io/part-of=sample-app\n      kubectl label roles sealed-secrets-key-admin app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label roles sealed-secrets-service-proxier app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label rolebindings sealed-secrets-key-admin app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label rolebindings sealed-secrets-service-proxier app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label services sealed-secrets app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label services sealed-secrets-metrics app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label deployments sealed-secrets app.kubernetes.io/part-of=sample-app -n sealed-secrets\n\n  helm (install with dry-run)\n\n    h --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --label=app.kubernetes.io/part-of=sample-app --dry-run; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n    The following resources do not exist and can be labeled at a later time:\n\n      kubectl label serviceaccounts sealed-secrets app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label clusterroles secrets-unsealer app.kubernetes.io/part-of=sample-app\n      kubectl label clusterrolebindings sealed-secrets app.kubernetes.io/part-of=sample-app\n      kubectl label roles sealed-secrets-key-admin app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label roles sealed-secrets-service-proxier app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label rolebindings sealed-secrets-key-admin app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label rolebindings sealed-secrets-service-proxier app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label services sealed-secrets app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label services sealed-secrets-metrics app.kubernetes.io/part-of=sample-app -n sealed-secrets\n      kubectl label deployments sealed-secrets app.kubernetes.io/part-of=sample-app -n sealed-secrets\n\n  helm (install)\n\n    h --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --label=app.kubernetes.io/part-of=sample-app; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n      🏷️ labeled object /v1/serviceaccounts \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/clusterroles \"secrets-unsealer\" in namespace \"\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/clusterrolebindings \"sealed-secrets\" in namespace \"\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/services \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/services \"sealed-secrets-metrics\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object apps/v1/deployments \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/namespaces \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n\n# Labeler with a sample OCM ManifestWork as output\n  with kubectl and kustomize:\n\n    k apply -f examples/kubectl/pass --label=app.kubernetes.io/part-of=sample --context=kind-kind --namespace=temp --overwrite --l-mw-create\n\n    deployment.apps/my-app-deployment2 unchanged\n    service/my-app-service2 unchanged\n      deployment.apps/my-app-deployment2 already has label app.kubernetes.io/part-of=sample\n      service/my-app-service2 already has label app.kubernetes.io/part-of=sample\n      🏷️ labeled object /v1/namespaces \"temp\" with app.kubernetes.io/part-of=sample\n\n    apiVersion: work.open-cluster-management.io/v1\n    kind: ManifestWork\n    metadata:\n        name: change-me\n    spec:\n        workload:\n            manifests: []\n\n# Labeler with a KubeStellar BindingPolicy as output\nYou can give command line arguments to trigger the output (and creation) of a bindingpolicy for use with KubeStellar\n\n    --l-bp-create \n    --l-bp-clusterselector=location-group=edge \n    --l-bp-wantsingletonreportedstate \n    --l-bp-name=my-test\n    --l-bp-wds=wds1 (this triggers an attempt to create the bindingpolicy object)\n\n\n  with kubectl and kustomize:\n\n    k --context=kind-kind apply -f examples/kubectl/pass --label=app.kubernetes.io/part-of=sample2 -n temp --overwrite --l-bp-create --l-bp-clusterselector=location-group=edge --l-bp-wantsingletonreportedstate --l-bp-name=my-test --l-bp-wds=wds1\n\n    deployment.apps/my-app-deployment2 unchanged\n    service/my-app-service2 unchanged\n      deployment.apps/my-app-deployment2 already has label app.kubernetes.io/part-of=sample2\n      service/my-app-service2 already has label app.kubernetes.io/part-of=sample2\n      🏷️ labeled object /v1/namespaces \"temp\" with app.kubernetes.io/part-of=sample2\n\n      🚀 Attempting to create BindingPolicy object \"my-test\" in WDS namespace \"wds1\"\n\n\n  with helm:\n\n    h --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --label=app.kubernetes.io/part-of=sample-app --l-bp-create --l-bp-clusterselector=location-group=edge --l-bp-wantsingletonreportedstate --l-bp-name=my-test; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n    NAME: sealed-secrets\n    LAST DEPLOYED: Tue Apr  9 12:01:43 2024\n    NAMESPACE: sealed-secrets\n    STATUS: deployed\n    REVISION: 1\n    TEST SUITE: None\n    NOTES:\n    ** Please be patient while the chart is being deployed **\n\n    You should now be able to create sealed secrets.\n\n    1. Install the client-side tool (kubeseal) as explained in the docs below:\n\n        https://github.com/bitnami-labs/sealed-secrets#installation-from-source\n\n    2. Create a sealed secret file running the command below:\n\n        kubectl create secret generic secret-name --dry-run=client --from-literal=foo=bar -o [json|yaml] | \\\n        kubeseal \\\n          --controller-name=sealed-secrets \\\n          --controller-namespace=sealed-secrets \\\n          --format yaml \u003e mysealedsecret.[json|yaml]\n\n    The file mysealedsecret.[json|yaml] is a commitable file.\n\n    If you would rather not need access to the cluster to generate the sealed secret you can run:\n\n        kubeseal \\\n          --controller-name=sealed-secrets \\\n          --controller-namespace=sealed-secrets \\\n          --fetch-cert \u003e mycert.pem\n\n    to retrieve the public cert used for encryption and store it locally. You can then run 'kubeseal --cert mycert.pem' instead to use the local cert e.g.\n\n        kubectl create secret generic secret-name --dry-run=client --from-literal=foo=bar -o [json|yaml] | \\\n        kubeseal \\\n          --controller-name=sealed-secrets \\\n          --controller-namespace=sealed-secrets \\\n          --format [json|yaml] --cert mycert.pem \u003e mysealedsecret.[json|yaml]\n\n    3. Apply the sealed secret\n\n        kubectl create -f mysealedsecret.[json|yaml]\n\n    Running 'kubectl get secret secret-name -o [json|yaml]' will show the decrypted secret that was generated from the sealed secret.\n\n    Both the SealedSecret and generated Secret must have the same name and namespace.\n      🏷️ labeled object /v1/serviceaccounts \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/clusterroles \"secrets-unsealer\" in namespace \"\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/clusterrolebindings \"sealed-secrets\" in namespace \"\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/services \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/services \"sealed-secrets-metrics\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object apps/v1/deployments \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/namespaces \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n\n    apiVersion: control.kubestellar.io/v1alpha1\n    kind: BindingPolicy\n    metadata:\n        name: my-test\n    wantSingletonReportedState: true\n    clusterSelectors:\n        - matchLabels:\n            location-group: edge\n    downsync:\n        - objectSelectors:\n            - matchLabels:\n                app.kubernetes.io/part-of: sample-app\n\n# Labeler with deployment to multiple contexts\nIf your in a jam and need kubectl or helm to deploy to multiple context, just add \"--l-remote-contexts=wds1,wds2\" to quickly deploy packages to multiple remote contexts. Assumes all contexts are in the original kubeconfig. (TODO - add params list of --kubeconfig in --l-remote-kubeconfigs and iterate to find the right one, then break)\n\n  with kubectl:\n\n    k apply -f examples/kubectl/pass --label=app.kubernetes.io/part-of=sample --context=kind-kind --namespace=temp --overwrite --l-remote-contexts=wds1,wds2  kind-kind/default ⎈ \n\n    deployment.apps/my-app-deployment2 unchanged\n    service/my-app-service2 unchanged\n      deployment.apps/my-app-deployment2 already has label app.kubernetes.io/part-of=sample\n      service/my-app-service2 already has label app.kubernetes.io/part-of=sample\n      🏷️ labeled object /v1/namespaces \"temp\" with app.kubernetes.io/part-of=sample\n\n    attempting deployment to contexts: [wds1 wds2]\n    error: context \"wds1\" does not exist\n    exit status 1\n    error: context \"wds2\" does not exist\n    exit status 1\n\n  with helm:\n\n    h --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --label=app.kubernetes.io/part-of=sample-app --l-remote-contexts=wds1,wds2; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets \n    NAME: sealed-secrets\n    LAST DEPLOYED: Tue Apr  9 13:29:24 2024\n    NAMESPACE: sealed-secrets\n    ...\n    Both the SealedSecret and generated Secret must have the same name and namespace.\n      🏷️ labeled object /v1/serviceaccounts \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object rbac.authorization.k8s.io/v1/clusterroles \"secrets-unsealer\" in namespace \"\" with app.kubernetes.io/part-of=sample-app\n      🏷️ labeled object /v1/namespaces \"sealed-secrets\" with app.kubernetes.io/part-of=sample-app\n    ...\n\n    attempting deployment to contexts: [wds1 wds2]\n    Error: INSTALLATION FAILED: Kubernetes cluster unreachable: context \"wds1\" does not exist\n    exit status 1\n    Error: INSTALLATION FAILED: Kubernetes cluster unreachable: context \"wds2\" does not exist\n    exit status 1\n\n# 2 - a command that works kinda like grep. You can run grep against a file as input or run grep against a command as output (linux pipe command)\n\n    grep \"apple\" example.txt\n\n  or\n\n    echo \"This is an example text with an apple\" | grep \"apple\"\n\nWhy not create a command that can do the same for labeling Kubernetes resources\n\n    labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind /path/to/myapp\n\n  or\n\n    (helm install with --debug mode)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --debug | ./labeler -l app.kubernetes.io/part-of=sealed-secrets -k ~/.kube/config -c kind-kind\n\n  or\n\n    (helm install without --debug mode)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace |  ./labeler -l app.kubernetes.io/part-of=sealed-secrets -k ~/.kube/config -c kind-kind\n\n  or\n\n    (helm template run - no installation)   \n    helm --kube-context=kind-kind template sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run |  ./labeler -l app.kubernetes.io/part-of=sealed-secrets -k ~/.kube/config -c kind-kind\n\n  or\n\n    (helm --dry-run - no installation)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sealed-secrets -k ~/.kube/config -c kind-kind\n\n  or\n    \n    (kubectl apply -f)\n    kubectl apply -f deployment.yml | ./labeler -l app.kubernetes.io/part-of=my-kubectl-app -k ~/.kube/config -c kind-kind\n\n  or\n    \n    (kustomize - 'kubectl -k')\n    kubectl apply -k kustomization.yml | ./labeler -l app.kubernetes.io/part-of=my-kustomize-app -k ~/.kube/config -c kind-kind\n\n\nThe result, in all cases, would be output of the yaml used to create resources and then labeling with your desired label. If you are running in template or --dry-run where there is no 'apply' of the object definitions, then the label commands are furnished as output\n\n\n\nTraditional use of helm\n\n    helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --debug\n\nUsing labeler as a piped command\n\n  install with debug (native yaml - resources applied, labeling succeeds)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --debug | ./labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n  install with dry-run (native yaml - but does not apply resources, so labeling may not work unless resource exist from a previous helm install - which is cool)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n  template run (native yaml - but does not apply resources, so labeling may not work unless resource exist from a previous helm install - which is cool)\n    helm --kube-context=kind-kind template sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n  plain install (uses history hack)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace | ./labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind; helm --kube-context=kind-kind uninstall sealed-secrets -n sealed-secrets\n\n\nworks like this...\n\n    kubectl (bunch of files in a path)\n        (without error from kubectl)\n          kubectl --context=kind-kind apply -f ./examples/kubectl/pass | ./labeler -l app.kubernetes.io/part-of=sample-value\n        (with error returning from kubectl)\n          kubectl --context=kind-kind apply -f ./examples/kubectl/fail | ./labeler -l app.kubernetes.io/part-of=sample-value \n    \n    kubectl (single file)\n        kubectl --context=kind-kind apply -f ./examples/kubectl/pass/deployment.yml | ./labeler -l app.kubernetes.io/part-of=another-sample-value\n    \n    kustomize\n        kubectl --context=kind-kind apply -k ./examples/kustomize | ./labeler -l app.kubernetes.io/part-of=sample-value\n\n    helm (local chart)\n        helm --kube-context=kind-kind install my-release-name ./mychart | ./labeler app.kubernetes.io/part-of=my-release-value\n\n    helm (remote chart)\n        helm --kube-context=kind-kind repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets\n        helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace | ./labeler app.kubernetes.io/part-of=sample-value\n\n## get started:\n\nYou need a kubernetes, go, kubectl, helm environment  - create one with Kind:\n[Zero to Kube and GO in 90 Seconds](https://clubanderson.medium.com/zero-to-kube-and-go-in-90-seconds-f6f4730ab265)\n\n### Install with brew, or clone and build\n```\n    brew tap clubanderson/labeler https://github.com/clubanderson/labeler\n    brew update\n    brew install labeler\n``` \n  or -\n```\n    git clone https://github.com/clubanderson/labeler\n    cd labeler\n    make build\n    make install\n```\n  then -\n```\n    alias k=\"labeler kubectl\"\n    alias h=\"labeler helm\"\n```\n  optional - edit your rc file (./zshrc) (or just run these commands on your local shell)\n```\n    alias k='labeler kubectl'  # you could also replace 'kubectl' (looking into this)\n    alias h='labeler helm'     # you could also replace 'helm' (looking into this)\n```\n  \n### to test:\n\n    helm --kube-context=kind-kind repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets\n    \n    passing test:\n      helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace | ./labeler -l app.kubernetes.io/part-of=sample-value\n    \n    failing test ('-l' missing from command)\n      helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace | ./labeler -l app.kubernetes.io/part-of=sample-value\n    \n    - or -\n\n    passing test:\n      helm --kube-context=kind-kind install nginx oci://ghcr.io/nginxinc/charts/nginx-ingress -n nginx --create-namespace --version 1.2.0 | ./labeler -l app.kubernetes.io/part-of=sample-value\n\n    - or -\n\n    failing test (missing kubeconfig)\n      helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sample-value --kubeconfig eks.config --context kind-kind\n\n\n    passing test (context and kubeconfig exist)\n      helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sample-value --kubeconfig ~/.kube/config --context kind-kind\n\n    - or - (on ubuntu)\n\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind\n\n    (note the use of 'exec' to get the command into history)\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace \u003e exec | ./labeler -l app.kubernetes.io/part-of=sample-value -k ~/.kube/config -c kind-kind\n\n### to reset:\n\n    helm uninstall sealed-secrets -n sealed-secrets\n    helm uninstall nginx -n nginx\n\n### sample output:\n\n    #1\n\n    helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run | ./labeler -l app.kubernetes.io/part-of=sample-value --kubeconfig ~/.kube/config --context kind-kind\n    \n    data is from pipe\n    YAML data detected in stdin\n        🏷️ labeled object rbac.authorization.k8s.io/v1/clusterroles \"secrets-unsealer\" in namespace \"\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/clusterrolebindings \"sealed-secrets\" in namespace \"\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object /v1/services \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object /v1/services \"sealed-secrets-metrics\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n    helm install nginx oci://ghcr.io/nginxinc/charts/nginx-ingress -n nginx --version 1.2.0 | ./labeler\n\n\n    #2\n\n    helm install nginx oci://ghcr.io/nginxinc/charts/nginx-ingress -n nginx --version 1.2.0 | ./labeler -l app.kubernetes.io/part-of=sample-value\n\n    data is from pipe\n    Pulled: ghcr.io/nginxinc/charts/nginx-ingress:1.2.0\n    Digest: sha256:6656e80c7975c393ea36bdfea3987f87d119c7d1501ba01eea89b739b69381bd\n    Error: INSTALLATION FAILED: cannot re-use a name that is still in use\n    No YAML data detected in stdin, will try to run again with YAML output\n    mac\n    command found: \"helm\"\n    original command: \"helm --kube-context=kind-kind install sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run\"\n\n    running command: helm --kube-context=kind-kind template sealed-secrets sealed-secrets/sealed-secrets -n sealed-secrets --create-namespace --dry-run \n        🏷️ labeled object /v1/serviceaccounts \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/clusterroles \"secrets-unsealer\" in namespace \"\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/clusterrolebindings \"sealed-secrets\" in namespace \"\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/roles \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-key-admin\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object rbac.authorization.k8s.io/v1/rolebindings \"sealed-secrets-service-proxier\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object /v1/services \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object /v1/services \"sealed-secrets-metrics\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n        🏷️ labeled object apps/v1/deployments \"sealed-secrets\" in namespace \"sealed-secrets\" with app.kubernetes.io/part-of=sample-value\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclubanderson%2Flabeler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclubanderson%2Flabeler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclubanderson%2Flabeler/lists"}