@media only screen and (max-width:991px){.lgUA-dd{display:block;}}/*!sc*/ @media only screen and (min-width:992px){.lgUA-dd{display:grid;grid-template-columns:20% 50% 30%;}}/*!sc*/ data-styled.g1[id="sc-bdnylx"]{content:"lgUA-dd,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.jqIXaF{grid-row-start:3;grid-row-end:4;}}/*!sc*/ data-styled.g2[id="sc-gtssRu"]{content:"jqIXaF,"}/*!sc*/ @media only screen and (max-width:991px){.cWHJEl{height:50px;grid-row-start:1;grid-row-end:2;border-bottom:none;display:block;}}/*!sc*/ @media only screen and (min-width:992px){.cWHJEl{height:80px;grid-row-start:1;grid-row-end:2;border-bottom:1px solid var(--unaccepted-color);display:grid;grid-template-columns:80% 10% 10%;}}/*!sc*/ data-styled.g3[id="sc-dlnjPT"]{content:"cWHJEl,"}/*!sc*/ .jusCDq{font-family:'Roboto';}/*!sc*/ @media only screen and (max-width:991px){.jusCDq{margin-left:0;}}/*!sc*/ @media only screen and (min-width:992px){.jusCDq{margin-left:var(--margin);}}/*!sc*/ data-styled.g5[id="sc-eCApGN"]{content:"jusCDq,"}/*!sc*/ .kiTsHr{-webkit-text-decoration:none;text-decoration:none;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;background-color:papayawhip;border-radius:10px;padding:calc(var(--prism-padding)/4);}/*!sc*/ @media only screen and (max-width:991px){.kiTsHr{margin-left:auto;margin-right:auto;}}/*!sc*/ @media only screen and (min-width:992px){.kiTsHr{margin-left:0;margin-right:0;}}/*!sc*/ data-styled.g6[id="sc-jSFkmK"]{content:"kiTsHr,"}/*!sc*/ .gmemPO{-webkit-text-decoration:none;text-decoration:none;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g7[id="sc-gKAblj"]{content:"gmemPO,"}/*!sc*/ .hPRGzu{display:inline-block;color:#48c1eb;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g8[id="sc-iCoHVE"]{content:"hPRGzu,"}/*!sc*/ .jqApVD{display:inline-block;color:#b77eff;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g9[id="sc-fujyUd"]{content:"jqApVD,"}/*!sc*/ @media only screen and (max-width:991px){.diRbeU{grid-row-start:2;grid-row-end:3;}}/*!sc*/ @media only screen and (min-width:992px){.diRbeU{grid-column-start:1;grid-column-end:2;grid-row-start:2;grid-row-start:3;}}/*!sc*/ data-styled.g14[id="sc-crzoUp"]{content:"diRbeU,"}/*!sc*/ .bDYZtZ{border:3px var(--border-color) solid;box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--accepted-color);overflow-wrap:break-word;}/*!sc*/ @media only screen and (max-width:991px){.bDYZtZ{margin:0;padding:calc(var(--prism-padding) / 2);max-width:calc(100vw - calc(var(--prism-padding) / 0.4));}}/*!sc*/ @media only screen and (min-width:992px){.bDYZtZ{grid-column-start:1;grid-column-end:2;margin:var(--prism-padding);padding:var(--prism-padding);}}/*!sc*/ .beZpRy{border:3px var(--border-color) solid;box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--unaccepted-color);overflow-wrap:break-word;}/*!sc*/ @media only screen and (max-width:991px){.beZpRy{margin:0;padding:calc(var(--prism-padding) / 2);max-width:calc(100vw - calc(var(--prism-padding) / 0.4));}}/*!sc*/ @media only screen and (min-width:992px){.beZpRy{grid-column-start:1;grid-column-end:2;margin:var(--prism-padding);padding:var(--prism-padding);}}/*!sc*/ data-styled.g15[id="sc-dIsAE"]{content:"bDYZtZ,beZpRy,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g16[id="sc-bqGHjH"]{content:"jOGTxR,"}/*!sc*/ .hqplyp{color:gray;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g17[id="sc-ksluoS"]{content:"hqplyp,"}/*!sc*/ .biJanX{text-align:right;font-style:italic;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g18[id="sc-hBMVcZ"]{content:"biJanX,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g19[id="sc-fnVYJo"]{content:"hbxbBL,"}/*!sc*/ .gGxjsg{width:40%;height:5px;background-color:var(--unaccepted-color);border:none;margin:auto;margin-top:15px;margin-bottom:10px;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g20[id="sc-fFSRdu"]{content:"gGxjsg,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g21[id="sc-bkbjAj"]{content:"jRzNCt,"}/*!sc*/ @media only screen and (max-width:991px){.bYuBoO{grid-row-start:3;grid-row-end:4;}}/*!sc*/ @media only screen and (min-width:992px){.bYuBoO{grid-column-start:2;grid-column-end:3;padding:calc(var(--prism-padding) /1);}}/*!sc*/ data-styled.g22[id="sc-iemXMA"]{content:"bYuBoO,"}/*!sc*/ .kUvyRY{box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--primary-color);overflow-wrap:break-word;padding:calc(var(--prism-padding) / 2);border:1px solid blue;margin:calc(var(--prism-padding) / 2);}/*!sc*/ @media only screen and (max-width:991px){.kUvyRY{display:block;margin-left:0;margin-right:calc(var(--prism-padding) / 4);}}/*!sc*/ @media only screen and (min-width:992px){.kUvyRY{display:inline-block;}}/*!sc*/ data-styled.g23[id="sc-dIvqjp"]{content:"kUvyRY,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.kgfarp{-webkit-text-decoration:none;text-decoration:none;}}/*!sc*/ data-styled.g24[id="sc-hHEjAm"]{content:"kgfarp,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.jhbzHN{margin:calc(var(--prism-padding) / 4);}}/*!sc*/ data-styled.g25[id="sc-dlMBXb"]{content:"jhbzHN,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.ipBxef{float:right;padding-top:var(--prism-padding);}}/*!sc*/ data-styled.g26[id="sc-kfYqjs"]{content:"ipBxef,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.fNfboX{display:inline-block;padding:calc(var(--prism-padding) / 4);border:1px solid var(--secondary-color);color:var(--secondary-color);margin-right:calc(var(--prism-padding) / 4);margin-bottom:calc(var(--prism-padding) / 4);}}/*!sc*/ data-styled.g27[id="sc-fKgIGh"]{content:"fNfboX,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g28[id="sc-bCwgka"]{content:"kCbTfo,"}/*!sc*/ .eohSKo{color:gray;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g29[id="sc-iwaifL"]{content:"eohSKo,"}/*!sc*/ .dvQjiN{text-align:right;font-style:italic;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g30[id="sc-cxNIbT"]{content:"dvQjiN,"}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){.lnacFT{grid-column-start:2;grid-column-end:4;}}/*!sc*/ data-styled.g31[id="sc-lmgQde"]{content:"lnacFT,"}/*!sc*/ @media only screen and (max-width:991px){.dmJaPZ{padding:calc(var(--prism-padding) / 2);display:grid;grid-template-rows:auto auto auto;}}/*!sc*/ @media only screen and (min-width:992px){.dmJaPZ{padding:0;display:grid;grid-template-columns:62.5% 37.5%;grid-template-rows:auto auto;}}/*!sc*/ data-styled.g32[id="sc-iJCRLp"]{content:"dmJaPZ,"}/*!sc*/ .jVqPkz{border:3px solid var(--border-color);box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--primary-color);grid-row-start:1;grid-row-end:2;overflow-wrap:break-word;}/*!sc*/ @media only screen and (max-width:991px){.jVqPkz{padding:calc(var(--prism-padding) / 2);max-width:calc(100vw - calc(var(--prism-padding) / 0.4));}}/*!sc*/ @media only screen and (min-width:992px){.jVqPkz{margin:var(--prism-padding);padding:var(--prism-padding);}}/*!sc*/ data-styled.g33[id="sc-giAqnE"]{content:"jVqPkz,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g34[id="sc-ezzayL"]{content:"kJKIJS,"}/*!sc*/ body{position:absolute;top:0;margin:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen', 'Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue', sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--prism-padding:20px;--margin:1.62em;--box-shadow-size:6px;--box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--primary-color);--box-shadow-hover:10px 10px var(--primary-color);--easing:200ms ease-in-out;--primary-color:#cdf2ff;--accepted-color:#bbffb8;--unaccepted-color:#eee;--border-color:#c8c8c8;--secondary-color:#9547b7;--dark-color:#282936;height:100vh;width:100%;}/*!sc*/ #root{height:100%;}/*!sc*/ h1{display:block;font-size:2em;margin-block-start:0.67em;margin-block-end:0.67em;margin-inline-start:0px;margin-inline-end:0px;font-weight:bold;}/*!sc*/ h2{display:block;font-size:1.5em;margin-block-start:0.83em;margin-block-end:0.83em;margin-inline-start:0px;margin-inline-end:0px;font-weight:bold;}/*!sc*/ img{width:100%;}/*!sc*/ pre{overflow-wrap:auto;overflow-x:scroll;}/*!sc*/ blockquote{border-left:2px solid var(--unaccepted-color);margin-block-start:0px;margin-inline-start:0px;padding-left:20px;}/*!sc*/ data-styled.g45[id="sc-global-bcwoHH1"]{content:"sc-global-bcwoHH1,"}/*!sc*/ gt; kubectl get services NAME ..."/>

access azure kubernetes cluster using a NodePort

7/25/2019

I'm running a pod (website) and a simple service

apiVersion: v1
kind: Service
metadata:
  name: ui
spec:
  type: NodePort
  selector:
    app: ui
  ports:
  - protocol: TCP
    port: 80
    targetPort: 3000

gt; kubectl
get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR LABELS kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 83m <none> component=apiserver,provider=kubernetes ui NodePort 10.0.25.205 <none> 80:30180/TCP 53m app=ui <none>

Because this service is of type NodePort it opens a port on each cluster node. In my case I'm running kubernetes in Azure, single node setup. But how do I access my service/website?

gt; kubectl describe
service ui Name: ui Namespace: default Labels: <none> Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"v1","kind":"Service","metadata": {"annotations":{},"name":"ui","namespace":"default"},"spec":{"ports":[{"port":80,"protocol"... Selector: app=ui Type: NodePort IP: 10.0.25.205 Port: <unset> 80/TCP TargetPort: 3000/TCP NodePort: <unset> 30180/TCP Endpoints: 10.244.0.14:3000,10.244.0.15:3000 Session Affinity: None External Traffic Policy: Cluster Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Type 29m service-controller NodePort -> LoadBalancer Normal EnsuringLoadBalancer 29m service-controller Ensuring load balancer Normal EnsuredLoadBalancer 27m service-controller Ensured load balancer Normal Type 10m service-controller LoadBalancer -> NodePort Normal DeletingLoadBalancer 10m service-controller Deleting load balancer Normal DeletedLoadBalancer 9m5s service-controller Deleted load balancer

I don't see an external IP.

For example, if I change NodePort to LoadBalancer I get an external IP and I can access my website, but how can I do this with NodePort?

-- Jeanluca Scaljeri
azure
azure-kubernetes
kubernetes

2 Answers

7/26/2019

As far as I know, the AKS is a managed service and it just exposes the master which is also managed by Azure to control all the actions. The slave nodes do not expose and do not have the external IP in default.

In the AKS cluster, you only can access the applications through the service with a load balancer or the ingress(which also uses the load balancer for its service).

If you really want to use the node type for your service, there is also a way to solve it. You can create public IPs manually and associate them to the nodes that you want to create the services with node type. Then the nodes have the external IPs. But all operations for AKS Iaas are not recommended. So the load balancer type is the most appropriate way for the service if you want to access them from the Internet.

-- Charles Xu
Source: StackOverflow

7/25/2019

You can get the IP of you nodes by querying the nodes from the kubernetes api:

kubectl get nodes -o wide

It will print the IP of each node. Since a NodePort is exposed on all nodes, you can use any node to access the service.

-- Thomas
Source: StackOverflow