Skip to content

Instantly share code, notes, and snippets.

@InAnimaTe
Created May 6, 2020 01:23
Show Gist options
  • Select an option

  • Save InAnimaTe/9aa4838fe8f18822aa17a8b23750b541 to your computer and use it in GitHub Desktop.

Select an option

Save InAnimaTe/9aa4838fe8f18822aa17a8b23750b541 to your computer and use it in GitHub Desktop.
API Version weirdness...
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: engage-ingress
annotations:
kubernetes.io/ingress.class: nginx-external
spec:
rules:
- host: engage.staging.example.com
http:
paths:
- path: /
backend:
serviceName: engage
servicePort: 80
tls:
- hosts:
- engage.staging.example.com
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"networking.k8s.io/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.class":"nginx-external"},"name":"engage-ingress","namespace":"default"},"spec":{"rules":[{"host":"engage.playground.example.com","http":{"paths":[{"backend":{"serviceName":"engage","servicePort":80},"path":"/"}]}}],"tls":[{"hosts":["engage.playground.example.com"}]}}
kubernetes.io/ingress.class: nginx-external
creationTimestamp: "2020-05-06T00:56:19Z"
generation: 1
name: engage-ingress
namespace: default
resourceVersion: "145130300"
selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/engage-ingress
uid: 488bca0c-34cf-4122-a350-2bde500d0f3a
spec:
rules:
- host: engage.playground.example.com
http:
paths:
- backend:
serviceName: engage
servicePort: 80
path: /
tls:
- hosts:
- engage.playground.example.com
status:
loadBalancer:
ingress:
- hostname: a0901a268b2281examplee2ffbd16e2-7baadc2e29c1d5ab.elb.us-east-1.amazonaws.com
@InAnimaTe
Copy link
Author

InAnimaTe commented May 6, 2020

  1. kubectl apply -f engage-ing.yaml
  2. kubectl get ing/engage-ingress -o yaml

Why is apiVersion: extensions/v1beta1 when what I imported is networking.k8s.io/v1beta1??

@InAnimaTe
Copy link
Author

Amazing answers can be seen here: https://kubernetes.slack.com/archives/C09QYUH5W/p1588728259459200

Thanks to Liggit and others on Sig-Network!!

@StevenACoffman
Copy link

From Liggit in slack linked conversation above (for those who don't like to click on "one-weird-trick" links to slack conversations:

kubectl get ingress is ambiguous and prefers the first ingress resource found in APIs listed in discovery, which is extensions/v1beta1 for backwards compatibility
kubectl get ingress.v1beta1.networking.k8s.io fetches the same resource in the new API group
the API server can translate any persisted ingress resource into either version and returns it in the version you request
you can add --v=6 to the kubectl invocation you see the actual URLs being requested

discovery is dynamic
so as soon as the server is not serving extensions/v1beta1 ingress, kubectl will prefer the networking.k8s.io version
and since the extensions/v1beta1 days, we now put the most stable version first in discovery
so unqualified kubectl get ingress kubectl invocations will get v1 ingress (once extensions/v1beta1 is gone)
extensions/v1beta1 was the exception where a beta version had higher priority, because people hadn't started writing version-aware kubectl invocations yet (because we hadn't given them a way to at that point)

@InAnimaTe
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment