How can I retrieve the value of an annotation on a...
# kubernetes
How can I retrieve the value of an annotation on a kubernetes resource? ie. I have a service with the following annotations:
Copy code
    <|>: '{"default": "istio-ingressgateway"}'
    <|>: '{"https":"HTTP2"}'
    <|>: '{"ingress": true}'
    <|>: '{"network_endpoint_groups":{"443":"k8s1-5487ae62-istio-system-istio-ingressgateway-443-811432aa"},"zones":["us-east1-d"]}'
I'd like to extract the value of the
annotation in such a way that I can use it to retrieve a gcp network endpoint group like:
Copy code
const neg = gcp.compute.getNetworkEndpointGroup({
  name: "k8s1-5487ae62-istio-system-istio-ingressgateway-443-811432aa",
  zone: "us-east1-d"
I'm usually ok working with outputs, but pulling something that's in json in a property of a property has got me beat right now
I've grabbed the k8s resource with
- just trying to figure out how best to use
to extract what I need
Something like this should do the trick:
Copy code
export const neg_status = svc.metadata.annotations.apply(x => {
    const status = x['<|>'];
    const obj = JSON.parse(status);
    return obj["network_endpoint_groups"]["443"]

const neg = gcp.compute.getNetworkEndpointGroup({
    name: neg_status,
    zone: "us-east1-d"