Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label app.kubernetes.io/part-of when enabling add-ons #287

Open
roar-skinderviken opened this issue Aug 12, 2024 · 0 comments
Open

Add label app.kubernetes.io/part-of when enabling add-ons #287

roar-skinderviken opened this issue Aug 12, 2024 · 0 comments

Comments

@roar-skinderviken
Copy link

roar-skinderviken commented Aug 12, 2024

Summary

When running e.g.
microk8s enable ingress
13 resources will be added to the cluster. Trying to track down these resources is cumbersome, and would be a lot easier with label app.kubernetes.io/part-of, e.g.:

metadata:
  labels:
    app.kubernetes.io/part-of: ingress

Why is this important?

When using Flux and adding e.g. cloudnative-pg, some ingress resources need to be patched in order to expose Postgres. This is usually done with Kustomize. This is only possible (as far as I know) when having all YAML-files for e.g. ingress in the Flux infra-repo.

Can be solved like this in utils.sh, but this solution requires yq (I find jq below /snap/microk8s/current/user/bin/, but not yq).

    # extract the part-of label value
    local part_of_label=${manifest%%/*}

    # insert label app.kubernetes.io/part-of for all resources
    yq eval ".metadata.labels[\"app.kubernetes.io/part-of\"] = \"$part_of_label\"" -i "${tmp_manifest}"

before this line

    "$SNAP/kubectl" "--kubeconfig=$SNAP_DATA/credentials/client.config" "$action" -f "${tmp_manifest}"

I tried to solve this using sed , but I couldn't figure out how to handle existing metadata/labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant