kind: List
apiVersion: v1
items:
# Create a service account
- apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: application-ui-app

# Roles for tokenreviews, projects, namespaces
- apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    name: application-ui-app
  rules:
  - apiGroups: ["*"]
    resources: ["*"]
    verbs: ["get", "list", "create", "update"]

# Bind roles to the serviceaccount
- apiVersion: rbac.authorization.k8s.io/v1beta1
  kind: ClusterRoleBinding
  metadata:
    name: application-ui-app
  roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: application-ui-app
  subjects:
    - kind: ServiceAccount
      name: application-ui-app
      namespace: default


# Route for a secure connection from outside
- apiVersion: route.openshift.io/v1
  kind: Route
  metadata:
    name: application-ui-app
  spec:
    host: application-ui-app-default.apps.cktestenv4.os.fyre.ibm.com
    to:
      kind: Service
      name: application-ui-app
      weight: 100

# Service
- apiVersion: v1
  kind: Service
  metadata:
    name: application-ui-app
    labels:
      app: application-ui-app
  spec:
    ports:
      - port: 3001
        targetPort: 3001
        protocol: TCP
        name: http
    selector:
      app: application-ui-app

# Deployment to launch the sample app
- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: application-ui-app
    labels:
      app: application-ui-app
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: application-ui-app
      spec:
        serviceAccountName: application-ui-app
        containers:
          - name: application-ui-app
            image: quay.io/open-cluster-management/application-ui:latest
            imagePullPolicy: Always
            ports:
            - containerPort: 3001
              protocol: TCP

# Oauth2 Client
- apiVersion: oauth.openshift.io/v1
  kind: OAuthClient
  metadata:
    name: application-ui-app
  grantMethod: auto
  redirectURIs:
  - https://localhost:3001/multicloud/applications/auth/callback
  secret: application-ui-app-test-secret