# ------------------- Dashboard Service Account ------------------- #

apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app: tekton-dashboard
  name: tekton-dashboard
  namespace: tekton-pipelines
---
# ------------------- Extension Resource Definition ------------------- #
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: extensions.dashboard.tekton.dev
spec:
  group: dashboard.tekton.dev
  names:
    kind: Extension
    plural: extensions
    categories:
    - all
    - tekton-pipelines
  scope: Namespaced
  # Opt into the status subresource so metadata.generation
  # starts to increment
  subresources:
    status: {}
  version: v1alpha1
---
# ------------------- Dashboard Role & Role Binding ------------------- #
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: tekton-dashboard-minimal
  namespace: tekton-pipelines
rules:
- apiGroups: ["apiextensions.k8s.io"]
  resources: ["customresourcedefinitions"]
  verbs: ["get", "list"]
- apiGroups: ["security.openshift.io"]
  resources: ["securitycontextconstraints"]
  verbs: ["use"]
- apiGroups: ["route.openshift.io"]
  resources: ["routes"]
  verbs: ["get", "list"]
- apiGroups: ["extensions", "apps"]
  resources: ["ingresses"]
  verbs: ["get", "list", "watch"]
- apiGroups: [""]
  resources: ["serviceaccounts"]
  verbs: ["get", "list", "update", "patch"]
- apiGroups: [""]
  resources: ["pods", "services"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: [""]
  resources: ["pods/log", "namespaces", "events"]
  verbs: ["get", "list", "watch"]
- apiGroups: [""]
  resources: ["secrets", "configmaps"]
  verbs: ["get", "list", "create", "update", "watch", "delete"]
- apiGroups: ["extensions", "apps"]
  resources: ["deployments"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["tekton.dev"]
  resources: ["tasks", "clustertasks", "taskruns", "pipelines", "pipelineruns", "pipelineresources",
    "conditions"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["tekton.dev"]
  resources: ["taskruns/finalizers", "pipelineruns/finalizers"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["tekton.dev"]
  resources: ["tasks/status", "clustertasks/status", "taskruns/status", "pipelines/status",
    "pipelineruns/status"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["dashboard.tekton.dev"]
  resources: ["extensions"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["tekton.dev"]
  resources: ["eventlisteners", "triggerbindings", "triggertemplates"]
  verbs: ["get", "list", "create", "update", "delete", "patch", "watch", "add"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tekton-dashboard-minimal
subjects:
- kind: ServiceAccount
  name: tekton-dashboard
  namespace: tekton-pipelines
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: tekton-dashboard-minimal
---
# ------------------- Dashboard Deployment ------------------- #
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tekton-dashboard
  namespace: tekton-pipelines
  labels:
    app: tekton-dashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tekton-dashboard
  template:
    metadata:
      name: tekton-dashboard
      labels:
        app: tekton-dashboard
    spec:
      serviceAccountName: tekton-dashboard
      containers:
      - name: tekton-dashboard
        image: gcr.io/tekton-releases/github.com/tektoncd/dashboard/cmd/dashboard@sha256:ae7ddb93a985cd190c1789533445de506275896826bb210d9fd76bf19438eb82
        ports:
        - containerPort: 9097
        livenessProbe:
          httpGet:
            path: /health
            port: 9097
        readinessProbe:
          httpGet:
            path: /readiness
            port: 9097
        resources:
        env:
        - name: PORT
          value: "9097"
        - name: WEB_RESOURCES_DIR
          value: /var/run/ko/web
        - name: PIPELINE_RUN_SERVICE_ACCOUNT
          value: ""
        - name: INSTALLED_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
---
# ------------------- Dashboard Service ------------------- #
kind: Service
apiVersion: v1
metadata:
  name: tekton-dashboard
  namespace: tekton-pipelines
  labels:
    app: tekton-dashboard
spec:
  ports:
  - name: http
    protocol: TCP
    port: 9097
    targetPort: 9097
  selector:
    app: tekton-dashboard

---
# The contents of this file should be included in both the Tekton dashboard config directory
# and config/release/gcr-tekton-dashboard.yaml

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: pipeline0-task
  namespace: tekton-pipelines
spec:
  inputs:
    resources:
    - name: git-source
      type: git
    params:
    - name: pathToResourceFiles
      description: The path to the resource files to apply
      default: /workspace/git-source
      type: string
    - name: apply-directory
      description: The directory from which resources are to be applied
      default: "."
      type: string
    - name: target-namespace
      description: The namespace in which to create the resources being imported
      default: tekton-pipelines
      type: string
  steps:
  - name: kubectl-apply
    image: lachlanevenson/k8s-kubectl@sha256:6944392a5ab6f762addbe3b3d8fcca7f47abdc44ff6076a6d18dc08510597e30
    command:
    - kubectl
    args:
    - apply
    - -f
    - $(inputs.params.pathToResourceFiles)/$(inputs.params.apply-directory)
    - -n
    - $(inputs.params.target-namespace)

---
# The contents of this file should be included in both the Tekton dashboard config directory
# and config/release/gcr-tekton-dashboard.yaml

apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: pipeline0
  namespace: tekton-pipelines
spec:
  resources:
  - name: git-source
    type: git
  params:
  - name: pathToResourceFiles
    description: The path to the resource files to apply
    default: /workspace/git-source
    type: string
  - name: apply-directory
    description: The directory from which resources are to be applied
    default: "."
    type: string
  - name: target-namespace
    description: The namespace in which to create the resources being imported
    default: tekton-pipelines
    type: string
  tasks:
  - name: pipeline0-task
    taskRef:
      name: pipeline0-task
    params:
    - name: pathToResourceFiles
      value: $(params.pathToResourceFiles)
    - name: apply-directory
      value: $(params.apply-directory)
    - name: target-namespace
      value: $(params.target-namespace)
    resources:
      inputs:
      - name: git-source
        resource: git-source

---
