Skip to content

Commit

Permalink
Update analysis monitoring binding
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunn1 committed Oct 7, 2023
1 parent ca55446 commit 4665164
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 94 deletions.
180 changes: 91 additions & 89 deletions bootstrap/ansible/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,95 +12,97 @@
- openshift-gitops-server

tasks:
- name: Get Ingress from Cluster
k8s_info:
api_version: config.openshift.io/v1
kind: Ingress
name: cluster
namespace: openshift-ingress
register: ingress

- name: Get sub_domain from ingress
set_fact:
sub_domain: "{{ ingress | json_query('resources[0].spec.domain')}}"

- name: Create cluster-admins group
kubernetes.core.k8s:
state: present
definition:
apiVersion: user.openshift.io/v1
kind: Group
metadata:
name: cluster-admins
users:
- admin
- opentlc-mgr

- name: Create openshift-gitops-operator namespace
kubernetes.core.k8s:
name: openshift-gitops-operator
api_version: v1
kind: Namespace
state: present

- name: Create Operator Group
kubernetes.core.k8s:
state: present
definition:
api_version: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: gitops
namespace: openshift-gitops-operator
spec:
upgradeStrategy: Default

- name: deploy-gitops-operator
k8s:
src: files/gitops-operator/subscription.yaml
state: present

- name: Sleep for 30 seconds
wait_for:
timeout: 30

- name: Check that all deployments are up and running
command: "oc rollout status deployment {{ item }} -n openshift-gitops"
with_items: "{{ gitops_deployments }}"

- name: Give application-controller cluster-admin permissions
kubernetes.core.k8s:
state: present
src: files/gitops-operator/application-controller-rolebinding.yaml

- name: Deploy CMP Configuration
kubernetes.core.k8s:
state: present
src: files/gitops-operator/setenv-cmp-plugin-cm.yaml

- name: Update openshift-gitops-instance
kubernetes.core.k8s:
state: present
definition: "{{ lookup('template', 'argocd-cr.yaml.j2') }}"

- name: Sleep for 10 seconds
wait_for:
timeout: 10

- name: Check that all deployments are up and running
command: "oc rollout status deployment {{ item }} -n openshift-gitops"
with_items: "{{ gitops_deployments }}"

- name: Deploy infra applications
kubernetes.core.k8s:
state: present
src: "{{ item }}"
with_items:
- files/applications/pipelines-operator.yaml
- files/applications/web-terminal-operator.yaml

# Todo: Check health of apps
- name: Wait 30 seconds for deployment
# - name: Get Ingress from Cluster
# k8s_info:
# api_version: config.openshift.io/v1
# kind: Ingress
# name: cluster
# namespace: openshift-ingress
# register: ingress

# - name: Get sub_domain from ingress
# set_fact:
# sub_domain: "{{ ingress | json_query('resources[0].spec.domain')}}"

# - name: Create cluster-admins group
# kubernetes.core.k8s:
# state: present
# definition:
# apiVersion: user.openshift.io/v1
# kind: Group
# metadata:
# name: cluster-admins
# users:
# - admin
# - opentlc-mgr

# - name: Create openshift-gitops-operator namespace
# kubernetes.core.k8s:
# name: openshift-gitops-operator
# api_version: v1
# kind: Namespace
# state: present

# - name: Create Operator Group
# kubernetes.core.k8s:
# state: present
# definition:
# api_version: operators.coreos.com/v1
# kind: OperatorGroup
# metadata:
# name: gitops
# namespace: openshift-gitops-operator
# spec:
# upgradeStrategy: Default

# - name: deploy-gitops-operator
# k8s:
# src: files/gitops-operator/subscription.yaml
# state: present

# - name: Sleep for 30 seconds
# wait_for:
# timeout: 30

# - name: Check that all deployments are up and running
# command: "oc rollout status deployment {{ item }} -n openshift-gitops"
# with_items: "{{ gitops_deployments }}"

# - name: Give application-controller cluster-admin permissions
# kubernetes.core.k8s:
# state: present
# src: files/gitops-operator/application-controller-rolebinding.yaml

# - name: Deploy CMP Configuration
# kubernetes.core.k8s:
# state: present
# src: files/gitops-operator/setenv-cmp-plugin-cm.yaml

# - name: Update openshift-gitops-instance
# kubernetes.core.k8s:
# state: present
# definition: "{{ lookup('template', 'argocd-cr.yaml.j2') }}"

# - name: Sleep for 10 seconds
# wait_for:
# timeout: 10

# - name: Check that all deployments are up and running
# command: "oc rollout status deployment {{ item }} -n openshift-gitops"
# with_items: "{{ gitops_deployments }}"

# - name: Deploy infra applications
# kubernetes.core.k8s:
# state: present
# src: "{{ item }}"
# with_items:
# - files/applications/pipelines-operator.yaml
# - files/applications/web-terminal-operator.yaml

# # Todo: Check health of apps
# - name: Wait 30 seconds for deployment
# wait_for:
# timeout: 30

- name: Update users applicationset
kubernetes.core.k8s:
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/ansible/templates/user-appset.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ spec:
- list:
elements:
{% for n in range(1, users | int + 1 ) %}
- user: {{ n }}
- user: "{{ n }}"
{% endfor %}
template:
metadata:
name: "user{{ user }}"
name: "user{% raw %}{{ user }}{% endraw %}"
namespace: openshift-gitops
spec:
destination:
namespace: "user{{user}}-tools"
namespace: "user{% raw %}{{ user }}{% endraw %}-tools"
server: 'https://kubernetes.default.svc'
project: default
syncPolicy:
Expand All @@ -32,4 +32,4 @@ spec:
path: bootstrap/user
helm:
values: |
user: {{ user }}
user: "{% raw %}{{ user }}{% endraw %}"
2 changes: 1 addition & 1 deletion bootstrap/user/templates/prod/auth-monitoring-rb.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: analysis-monitoring-view
name: analysis-monitoring-view-user{{ .Values.user }}
namespace: user{{ .Values.user }}-prod
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down

0 comments on commit 4665164

Please sign in to comment.