# Copyright 2022 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.

---
apiVersion: v1
kind: Service
metadata:
  name: mosquitto
spec:
  selector:
    app: mosquitto
  type: ClusterIP
  ports:
    - protocol: TCP
      name: notls
      port: 1883
      targetPort: 1883
...
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mosquitto
spec:
  selector:
    matchLabels:
      app: mosquitto
  template:
    metadata:
      labels:
        app: mosquitto
    spec:
      containers:
        # We set a more precise container image ID with Kustomize
        - image: eclipse-mosquitto
          name: mosquitto
          livenessProbe:
            tcpSocket:
              port: 1883
            initialDelaySeconds: 5
            periodSeconds: 15
          readinessProbe:
            tcpSocket:
              port: 1883
            initialDelaySeconds: 5
            periodSeconds: 10
          ports:
            - containerPort: 1883
          resources:
            # Setting limits same as requests because GKE Autopilot only considers requests
            # See https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-resource-requests#resource-limits
            limits:
              cpu: "1000m"
              ephemeral-storage: "1Gi"
              memory: "1Gi"
            requests:
              cpu: "1000m"
              ephemeral-storage: "1Gi"
              memory: "1Gi"
          volumeMounts:
            - name: mosquitto-config
              mountPath: "/mosquitto/config"
      volumes:
        - name: mosquitto-config
          configMap:
            name: mosquitto
            items:
              - key: "mosquitto.conf"
                path: "mosquitto.conf"
...
