Kubernetes service external ip pending

后端 未结 20 1842
你的背包
你的背包 2020-11-28 02:38

I am trying to deploy nginx on kubernetes, kubernetes version is v1.5.2, I have deployed nginx with 3 replica, YAML file is below,

apiVersion: extensions/v1be         


        
相关标签:
20条回答
  • 2020-11-28 02:53

    Check kube-controller logs. I was able to solve this issue by setting the clusterID tags to the ec2 instance I deployed the cluster on.

    0 讨论(0)
  • 2020-11-28 02:53

    Delete existing service and create a same new service solved my problems. My problems is that the loading balancing IP I defines is used so that external endpoint is pending. When I changed a new load balancing IP it still couldn't work.

    Finally, delete existing service and create a new one solved my problem.

    0 讨论(0)
  • 2020-11-28 02:55

    If it is your private k8s cluster, MetalLB would be a better fit. Below are the steps.

    Step 1: Install MetalLB in your cluster

    kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/namespace.yaml
    kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/metallb.yaml
    # On first install only
    kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
    

    Step 2: Configure it by using a configmap

    apiVersion: v1
    kind: ConfigMap
    metadata:
      namespace: metallb-system
      name: config
    data:
      config: |
        address-pools:
        - name: default
          protocol: layer2
          addresses:
          - 172.42.42.100-172.42.42.105 #Update this with your Nodes IP range 
    

    Step 3: Create your service to get an external IP (would be a private IP though).

    FYR:

    Before MetalLB installation:

    After MetalLB installation:

    0 讨论(0)
  • I created a single node k8s cluster using kubeadm. When i tried PortForward and kubectl proxy, it showed external IP as pending.

    $ kubectl get svc -n argocd argocd-server
    NAME            TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
    argocd-server   LoadBalancer   10.107.37.153   <pending>     80:30047/TCP,443:31307/TCP   110s
    

    In my case I've patched the service like this:

    kubectl patch svc <svc-name> -n <namespace> -p '{"spec": {"type": "LoadBalancer", "externalIPs":["172.31.71.218"]}}'
    

    After this, it started serving over the public IP

    $ kubectl get svc argo-ui -n argo
    NAME      TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
    argo-ui   LoadBalancer   10.103.219.8   172.31.71.218   80:30981/TCP   7m50s
    
    0 讨论(0)
  • 2020-11-28 02:56

    There are three types of exposing your service Nodeport ClusterIP LoadBalancer

    When we use a loadbalancer we basically ask our cloud provider to give us a dns which can be accessed online Note not a domain name but a dns.

    So loadbalancer type does not work in our local minikube env.

    0 讨论(0)
  • 2020-11-28 02:57

    Use NodePort:

    $ kubectl run user-login --replicas=2 --labels="run=user-login" --image=kingslayerr/teamproject:version2  --port=5000
    
    $ kubectl expose deployment user-login --type=NodePort --name=user-login-service
    
    $ kubectl describe services user-login-service
    

    (Note down the port)

    $ kubectl cluster-info
    

    (IP-> Get The IP where master is running)

    Your service is accessible at (IP):(port)

    0 讨论(0)
提交回复
热议问题