Loading...
Loading...
Create a Gateway resource with listeners for HTTP, HTTPS, or both
npx skill4agent add missberg/envoy-skills eg-gatewayhttpProtocolshttphttpstls-passthroughtcpudpapiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: eg
spec:
# The controller name must match the Envoy Gateway installation.
# This is the default value; change it only for multi-tenant deployments
# where each tenant runs a separate Envoy Gateway controller.
controllerName: gateway.envoyproxy.io/gatewayclass-controllerWhen to use parametersRef: If you need to customize the Envoy proxy configuration (resource limits, access logging, custom bootstrap), attach an EnvoyProxy resource viaon the GatewayClass or Gateway:parametersRefyamlspec: parametersRef: group: gateway.envoyproxy.io kind: EnvoyProxy name: custom-proxy-config namespace: default # Required when set on GatewayClass
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ${Name}
namespace: default # TODO: Change to your target namespace
spec:
gatewayClassName: eg
listeners:
- name: http
protocol: HTTP
port: 80
# allowedRoutes controls which namespaces can attach Routes to this listener.
# "Same" = only Routes in the Gateway's namespace. "All" = any namespace.
allowedRoutes:
namespaces:
from: Same # TODO: Change to "All" for cross-namespace routingapiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ${Name}
namespace: default # TODO: Change to your target namespace
annotations:
# Uncomment to enable automatic certificate management with cert-manager.
# See the /eg-tls skill for full cert-manager integration.
# cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
gatewayClassName: eg
listeners:
- name: https
protocol: HTTPS
port: 443
# hostname is required for cert-manager to issue certificates.
# It also scopes which SNI values this listener accepts.
hostname: "*.example.com" # TODO: Set your domain
tls:
mode: Terminate
certificateRefs:
- kind: Secret
group: ""
name: example-tls # TODO: Name of the TLS Secret (cert-manager creates this)
allowedRoutes:
namespaces:
from: AllapiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ${Name}
namespace: default # TODO: Change to your target namespace
annotations:
# cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
gatewayClassName: eg
listeners:
# HTTP listener - typically used for HTTPS redirects
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All
# HTTPS listener - primary traffic endpoint
- name: https
protocol: HTTPS
port: 443
hostname: "*.example.com" # TODO: Set your domain
tls:
mode: Terminate
certificateRefs:
- kind: Secret
group: ""
name: example-tls # TODO: Name of the TLS Secret
allowedRoutes:
namespaces:
from: AllapiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ${Name}
namespace: default # TODO: Change to your target namespace
spec:
gatewayClassName: eg
listeners:
- name: tls-passthrough
protocol: TLS
port: 443
hostname: "app.example.com" # TODO: SNI hostname for routing
tls:
mode: Passthrough
allowedRoutes:
kinds:
- kind: TLSRoute # Only TLSRoute is valid for Passthrough mode
namespaces:
from: AllapiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ${Name}
namespace: default # TODO: Change to your target namespace
spec:
gatewayClassName: eg
listeners:
- name: tcp
protocol: TCP
port: 8088 # TODO: Set your TCP port
allowedRoutes:
kinds:
- kind: TCPRoute # Only TCPRoute is valid for TCP protocolapiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ${Name}
namespace: default # TODO: Change to your target namespace
spec:
gatewayClassName: eg
listeners:
- name: udp
protocol: UDP
port: 5300 # TODO: Set your UDP port
allowedRoutes:
kinds:
- kind: UDPRoute # Only UDPRoute is valid for UDP protocolkubectl apply -f gateway.yaml
kubectl get gateway/${Name} -o yamlAccepted: TrueProgrammed: Truekubectl describe gateway/${Name}export GATEWAY_HOST=$(kubectl get gateway/${Name} -o jsonpath='{.status.addresses[0].value}')
echo "Gateway address: $GATEWAY_HOST"allowedRoutesallowedRoutes:
kinds:
- kind: HTTPRoute # Only allow HTTPRoute, not GRPCRoute
namespaces:
from: Selector
selector:
matchLabels:
gateway-access: "true" # Only namespaces with this labelcertificateRefsapiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
name: allow-gateway-secret-ref
namespace: cert-namespace # TODO: Namespace where the Secret lives
spec:
from:
- group: gateway.networking.k8s.io
kind: Gateway
namespace: default # TODO: Namespace where the Gateway lives
to:
- group: ""
kind: SecretAccepted: TrueAccepted: TrueProgrammed: TrueallowedRoutes