# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START gke_ap_networking_tutorial]
---
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
  name: networking-managed-cert
spec:
  domains:
    - DOMAIN_NAME
    - www.DOMAIN_NAME
---
apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
  name: networking-fc
spec:
  redirectToHttps:
    enabled: true
    responseCodeName: MOVED_PERMANENTLY_DEFAULT
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  selector:
    matchLabels:
      app: frontend
  replicas: 2
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
      - name: echo-amd64
        image: us-docker.pkg.dev/google-samples/containers/gke/hello-app-cdn:1.0
---
apiVersion: v1
kind: Service
metadata:
  name: frontend
spec:
  type: LoadBalancer
  selector:
    app: frontend
  ports:
  - name: http
    port: 80
    targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: frontend
  annotations:
    networking.gke.io/managed-certificates: networking-managed-cert
    networking.gke.io/v1beta1.FrontendConfig: networking-fc
    kubernetes.io/ingress.global-static-ip-name: networking-tutorial
    kubernetes.io/ingress.class: gce
  labels:
    app: frontend
spec:
  defaultBackend:
    service:
      name: frontend
      port:
        number: 80
# [END gke_ap_networking_tutorial]
