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

Installing Kubecost on K8s v1.25 clusters fails due to PodSecurityPolicy #1773

Closed
michaelmdresser opened this issue Nov 1, 2022 · 8 comments · Fixed by #1824
Closed

Installing Kubecost on K8s v1.25 clusters fails due to PodSecurityPolicy #1773

michaelmdresser opened this issue Nov 1, 2022 · 8 comments · Fixed by #1824
Labels
bug Something isn't working v1.99

Comments

@michaelmdresser
Copy link
Contributor

To reproduce

Create a K8s v1.25 cluster with K3d:

k3d cluster create --image rancher/k3s:v1.25.3-rc3-k3s1

Confirm version:

kubectl version --short
Client Version: v1.25.3
Kustomize Version: v4.5.7
Server Version: v1.25.3-rc3+k3s1

Try to install the latest version of Kubecost (v1.98.0-rc.3):

helm upgrade \
    -i \
    --create-namespace kubecost \
    kubecost/cost-analyzer \
    --namespace kubecost \
    --version "1.98.0-rc.3"

Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "PodSecurityPolicy" in version "policy/v1beta1"

Expected behavior

Kubecost installs successfully on the K8s v1.25 cluster without any modification to default values.

Workaround

This can be worked around by disabling PSPs. Unfortunately, Grafana also must be disabled to remove its PSP.

helm upgrade \
    -i \
    --create-namespace kubecost \
    kubecost/cost-analyzer \
    --namespace kubecost \
    --version "1.98.0-rc.3" \
    --set "podSecurityPolicy.enabled=false" \
    --set "global.grafana.enabled=false" \
    --set "global.grafana.proxy=false"

Note that the Grafana proxy option has to be disabled because otherwise the Kubecost frontend container errors out due to the Grafana upstream being unavailable.

Fix ideas

@michaelmdresser michaelmdresser added bug Something isn't working P1 labels Nov 1, 2022
@michaelmdresser
Copy link
Contributor Author

michaelmdresser commented Nov 1, 2022

@lgmorand
Copy link

lgmorand commented Nov 1, 2022

+1. was coming to create a bug too.

@AjayTripathy
Copy link
Contributor

My suggestion is we document and make clear the workaround for v1.98 and implement it seamlessly in v1.99 since we probably need to give folks adequate warning before turning off PSPs, and most people on cloud providers are not yet on v1.25.

@michaelmdresser
Copy link
Contributor Author

We've also had a request that we place PSPs with SecurityContext constraints where appropriate, but I'm not sure how applicable they are -- I'm not familiar with our existing PSPs. Just noting for the record!

Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

cc @srpomeroy

@michaelmdresser
Copy link
Contributor Author

michaelmdresser commented Nov 1, 2022

There is also an alternative workaround that (might?) not disable Grafana in the process:

helm upgrade \
    -i \
    --create-namespace kubecost \
    kubecost/cost-analyzer \
    --namespace kubecost \
    --version "1.98.0-rc.3" \
    --set "podSecurityPolicy.enabled=false" \
    --set "networkCosts.podSecurityPolicy.enabled=false" \
    --set "prometheus.podSecurityPolicy.enabled=false" \
    --set "grafana.rbac.pspEnabled=false"

Haven't tested personally yet.

@fungiboletus
Copy link

Haven't tested personally yet.

I have and it works well. Thanks.

@zioproto
Copy link

Installation of Kubecost on Kubernetes 1.25 still fails when installing without Helm:

kubectl apply -f https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/master/kubecost.yaml --namespace kubecost

@AjayTripathy
Copy link
Contributor

Thanks for this heads up @zioproto , I think we generate that file from a template where we assume we're on helm less than 1.25. Let's modify the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v1.99
Projects
None yet
6 participants