stable/mongodb error while fetching service ip for external acess

7/23/2019

while trying to set service ip of mongo service i deployed using helm chart via

kubectl get svc --namespace default mymongo-mongodb --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"

I get error saying

executing "output" at : error calling index: index of untyped nil

Platform:

google cloud instance

kubernates version:

1.15.0

helm version

v2.14.2

Already sucessfully deployed the service and able to acess it via endpoints and via command

  kubectl run --namespace default mymongo-mongodb-client --rm --tty -i --restart='Never' --image bitnami/mongodb --command -- mongo admin --host mymongo-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD

But when i go for setting service-ip to access it outside cluster with

kubectl get svc --namespace default mymongo-mongodb --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"

get the error as:

Error executing template: template: output:1:10: executing "output" at : error calling index: index of untyped nil.

configurations made at value.yaml provided by helm mongodb chart

# Kubernetes service type
service:
  annotations: {}
  type: LoadBalancer
  # clusterIP: None
  port: 27017

  ## Specify the nodePort value for the LoadBalancer and NodePort service types.
  ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
  ##
  nodePort: 32007

  ## Specify the externalIP value ClusterIP service type.
  ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
  externalIPs: [102.226.201.198]

  ## Specify the loadBalancerIP value for LoadBalancer service types.
  ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer
  ##
  loadBalancerIP: 78.11.24.19/24

  ## Specify the loadBalancerSourceRanges value for LoadBalancer service types.
  ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service
  ##
  loadBalancerSourceRanges: [78.11.24.19/24,78.11.24.20/24]
-- Ayush Mishra
kubernetes
kubernetes-helm
mongodb

1 Answer

12/19/2019
kubectl get svc --namespace default mymongo-mongodb --template "{{- if .status.loadBalancer  }}{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}{{ end }}"
-- wow qing
Source: StackOverflow