primo
This commit is contained in:
126
GatewayAPI.txt
Normal file
126
GatewayAPI.txt
Normal file
@@ -0,0 +1,126 @@
|
||||
# Install Gateway API CRDs
|
||||
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/standard-install.yaml
|
||||
|
||||
kubectl get crd | grep gateway
|
||||
|
||||
kubectl create namespace nginx-gateway
|
||||
|
||||
kubectl apply --server-side -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/v2.4.1/deploy/crds.yaml
|
||||
kubectl apply -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/v2.4.1/deploy/nodeport/deploy.yaml
|
||||
|
||||
---- Gatway configuration ----
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: main-gateway
|
||||
namespace: nginx-gateway
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
gatewayClassName: nginx
|
||||
listeners:
|
||||
- allowedRoutes:
|
||||
namespaces:
|
||||
from: All
|
||||
hostname: poc1.italiadatacenter.com
|
||||
name: https
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
certificateRefs:
|
||||
- group: ""
|
||||
kind: Secret
|
||||
name: poc1-secret
|
||||
mode: Terminate
|
||||
- allowedRoutes:
|
||||
namespaces:
|
||||
from: All
|
||||
hostname: poc1.italiadatacenter.com
|
||||
name: http
|
||||
port: 80
|
||||
protocol: HTTP
|
||||
|
||||
|
||||
----- Nodeport service ---
|
||||
kubectl apply -f - <<EOF
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/instance: nginx-gateway
|
||||
app.kubernetes.io/managed-by: nginx-gateway-nginx
|
||||
app.kubernetes.io/name: main-gateway-nginx
|
||||
gateway.networking.k8s.io/gateway-name: main-gateway
|
||||
name: gateway-nginx-nodeport
|
||||
namespace: nginx-gateway
|
||||
spec:
|
||||
ports:
|
||||
- name: port-80
|
||||
nodePort: 30864
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
- name: port-443
|
||||
nodePort: 30874
|
||||
port: 443
|
||||
protocol: TCP
|
||||
targetPort: 443
|
||||
selector:
|
||||
app.kubernetes.io/instance: nginx-gateway
|
||||
app.kubernetes.io/managed-by: nginx-gateway-nginx
|
||||
app.kubernetes.io/name: main-gateway-nginx
|
||||
gateway.networking.k8s.io/gateway-name: main-gateway
|
||||
sessionAffinity: None
|
||||
type: NodePort
|
||||
EOF
|
||||
|
||||
----- httproute ---
|
||||
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: demo-route
|
||||
namespace: demo-apps
|
||||
spec:
|
||||
hostnames:
|
||||
- poc2.italiadatacenter.com
|
||||
parentRefs:
|
||||
- name: main-gateway
|
||||
namespace: nginx-gateway
|
||||
rules:
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /
|
||||
backendRefs:
|
||||
- name: app-v1
|
||||
port: 80
|
||||
|
||||
--- work area
|
||||
|
||||
kubectl edit gateway main-gateway -n nginx-gateway
|
||||
|
||||
add
|
||||
|
||||
- allowedRoutes:
|
||||
namespaces:
|
||||
from: cattle-system
|
||||
hostname: k8s.italiadatacenter.com
|
||||
name: k8s-https
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
certificateRefs:
|
||||
- group: ""
|
||||
kind: Secret
|
||||
name: k8s-secret
|
||||
mode: Terminate
|
||||
- allowedRoutes:
|
||||
namespaces:
|
||||
from: cattle-system
|
||||
hostname: k8s.italiadatacenter.com
|
||||
name: k8s-http
|
||||
port: 80
|
||||
protocol: HTTP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user