Giter VIP home page Giter VIP logo

Comments (5)

evanstucker-hates-2fa avatar evanstucker-hates-2fa commented on July 25, 2024

As an alternative, this script is hideous but functional:

deprecated_apis=(
networkpolicy,networking.k8s.io/v1
podsecuritypolicy,policy/v1beta1
daemonset,apps/v1beta2
deployment,apps/v1
statefulset,apps/v1
replicaset,apps/v1
)

for d in "${deprecated_apis[@]}"; do
  api=$(echo $d | cut -d, -f1)
  version=$(echo $d | cut -d, -f2)
  echo "===== These ${api} objects to be upgraded to \"${version}\""
  kubectl get $api -A -o json | jq -r ".items[] | select(.apiVersion != \"$version\") | \"\(.metadata.name) \(.metadata.namespace)\""
done

from kube-no-trouble.

stepanstipl avatar stepanstipl commented on July 25, 2024

Hi @evanstucker-hates-2fa, thanks for reporting this, but I think this might be a false alarm. It's not quite how kubent works. If you request a resource from K8s API, you can get it in different API versions, based on how your client requested it. This, however, is not related to how the resource was created. E.g. you create a NetworkPolicy using networking.k8s.io/v1, and when you call kubectl get you can get it back as extensions/v1beta1.

This is why the collectors use various "tricks", such as reading kubectl.kubernetes.io/last-applied-configuration annotation, to get the version that was used to create the resource.

You can see this by actually requesting the full version, in your case compare:

kubectl get networkpolicies.v1.networking.k8s.io redis -o jsonpath='{.apiVersion}'

vs

kubectl get networkpolicies.v1beta1.extensions redis -o jsonpath='{.apiVersion}'

I would like to verify this is indeed the case. Can you please share full manifest of one of the resources you mentioned (if these were created using kubectl)?

from kube-no-trouble.

evanstucker-hates-2fa avatar evanstucker-hates-2fa commented on July 25, 2024

Sneaky! Thanks for the explanation. You can close this issue.

from kube-no-trouble.

evanstucker-hates-2fa avatar evanstucker-hates-2fa commented on July 25, 2024

Yeah, here's what I'm seeing:

root@codefi-us-east-2:/mnt$ kubectl get networkpolicies.v1.networking.k8s.io redis -o jsonpath='{.apiVersion}'; echo
networking.k8s.io/v1
root@codefi-us-east-2:/mnt$ kubectl get networkpolicies.v1beta1.extensions redis -o jsonpath='{.apiVersion}'; echo
extensions/v1beta1

from kube-no-trouble.

stepanstipl avatar stepanstipl commented on July 25, 2024

Ok great, thank you for confirming 👍 , I'll close the issue. If you check the original manifest, or the kubectl.kubernetes.io/last-applied-configuration if present, it should confirm that the non-deprecated (networking.k8s.io/v1) API version was used to create the resource.

from kube-no-trouble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.