# Copyright 2020 The Tekton Authors
#
# 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: apps/v1
kind: Deployment
metadata:
  name: tekton-triggers-core-interceptors
  namespace: tekton-pipelines
  labels:
    app.kubernetes.io/name: core-interceptors
    app.kubernetes.io/component: interceptors
    app.kubernetes.io/instance: default
    app.kubernetes.io/version: "v0.26.1"
    app.kubernetes.io/part-of: tekton-triggers
    # tekton.dev/release value replaced with inputs.params.versionTag in triggers/tekton/publish.yaml
    triggers.tekton.dev/release: "v0.26.1"
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: core-interceptors
      app.kubernetes.io/component: interceptors
      app.kubernetes.io/instance: default
      app.kubernetes.io/part-of: tekton-triggers
  template:
    metadata:
      labels:
        app.kubernetes.io/name: core-interceptors
        app.kubernetes.io/component: interceptors
        app.kubernetes.io/instance: default
        app.kubernetes.io/version: "v0.26.1"
        app.kubernetes.io/part-of: tekton-triggers
        app: tekton-triggers-core-interceptors
        triggers.tekton.dev/release: "v0.26.1"
        # version value replaced with inputs.params.versionTag in triggers/tekton/publish.yaml
        version: "v0.26.1"
    spec:
      serviceAccountName: tekton-triggers-core-interceptors
      containers:
        - name: tekton-triggers-core-interceptors
          image: "gcr.io/tekton-releases/github.com/tektoncd/triggers/cmd/interceptors:v0.26.1@sha256:ffc13aab0d0e16836c98bdf15f516a7f9df4e3eed1184a64825193f6a2fa6753"
          ports:
            - containerPort: 8443
          args: ["-logtostderr", "-stderrthreshold", "INFO"]
          env:
            - name: SYSTEM_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: CONFIG_LOGGING_NAME
              value: config-logging-triggers
            - name: CONFIG_OBSERVABILITY_NAME
              value: config-observability-triggers
            - name: METRICS_DOMAIN
              value: tekton.dev/triggers
            # assuming service and deployment names are same always for consistency
            - name: INTERCEPTOR_TLS_SVC_NAME
              value: tekton-triggers-core-interceptors
            - name: INTERCEPTOR_TLS_SECRET_NAME
              value: tekton-triggers-core-interceptors-certs
          readinessProbe:
            httpGet:
              path: /ready
              port: 8443
              scheme: HTTPS
            initialDelaySeconds: 5
            periodSeconds: 10
            timeoutSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            # User 65532 is the distroless nonroot user ID
            runAsUser: 65532
            runAsGroup: 65532
            runAsNonRoot: true
            capabilities:
              drop:
                - "ALL"
            seccompProfile:
              type: RuntimeDefault