Skip to content

Commit 6b3361a

Browse files
authored
Add NodePort and LoadBalancer Service definitions to manifests (#86)
Also adds instructions for creating services in AWS, Azure, and GCP.
1 parent a8b3199 commit 6b3361a

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,56 @@ You can deploy NGINX Kubernetes Gateway on an existing Kubernetes 1.16+ cluster.
8686
nginx-gateway-5d4f4c7db7-xk2kq 2/2 Running 0 112s
8787
```
8888

89+
## Expose NGINX Kubernetes Gateway
90+
91+
You can gain access to NGINX Kubernetes Gateway by creating a `NodePort` Service or a `LoadBalancer` Service.
92+
93+
### Create a NodePort Service
94+
95+
Create a service with type `NodePort`:
96+
97+
```
98+
kubectl apply -f deploy/manifests/service/nodeport.yaml
99+
```
100+
101+
A `NodePort` service will randomly allocate one port on every node of the cluster. To access NGINX Kubernetes Gateway, use an IP address of any node in the cluster along with the allocated port.
102+
103+
### Create a LoadBalancer Service
104+
105+
Create a service with type `LoadBalancer` using the appropriate manifest for your cloud provider.
106+
107+
- For GCP or Azure:
108+
109+
```
110+
kubectl apply -f deploy/manifests/service/loadbalancer.yaml
111+
```
112+
113+
Lookup the public IP of the load balancer:
114+
115+
```
116+
kubectl get svc nginx-gateway -n nginx-gateway
117+
```
118+
119+
Use the public IP of the load balancer to access NGINX Kubernetes Gateway.
120+
121+
- For AWS:
122+
123+
```
124+
kubectl apply -f deploy/manifests/service/loadbalancer-aws-nlb.yaml
125+
```
126+
127+
In AWS, the NLB DNS name will be reported by Kubernetes in lieu of a public IP. To get the DNS name run:
128+
129+
```
130+
kubectl get svc nginx-gateway -n nginx-gateway
131+
```
132+
133+
In general, you should rely on the NLB DNS name, however for testing purposes you can resolve the DNS name to get the IP address of the load balancer:
134+
135+
```
136+
nslookup <dns-name>
137+
```
138+
89139
# Test NGINX Kubernetes Gateway
90140

91141
To test the NGINX Kubernetes Gateway run:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: nginx-gateway
5+
namespace: nginx-gateway
6+
annotations:
7+
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
8+
spec:
9+
type: LoadBalancer
10+
ports:
11+
- port: 80
12+
targetPort: 80
13+
protocol: TCP
14+
name: http
15+
selector:
16+
app: nginx-gateway
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: nginx-gateway
5+
namespace: nginx-gateway
6+
spec:
7+
externalTrafficPolicy: Local
8+
type: LoadBalancer
9+
ports:
10+
- port: 80
11+
targetPort: 80
12+
protocol: TCP
13+
name: http
14+
selector:
15+
app: nginx-gateway
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: nginx-gateway
5+
namespace: nginx-gateway
6+
spec:
7+
type: NodePort
8+
ports:
9+
- port: 80
10+
targetPort: 80
11+
protocol: TCP
12+
name: http
13+
selector:
14+
app: nginx-gateway

0 commit comments

Comments
 (0)