Skip to content

Commit 45f4887

Browse files
committed
[IDG-15757] - [API] Improve our development env for OpenShift
Signed-off-by: Mauricio Magnani <[email protected]>
1 parent 85c4398 commit 45f4887

File tree

14 files changed

+328
-0
lines changed

14 files changed

+328
-0
lines changed

automation/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Overview
2+
--------
3+
4+
This is a ansible based project to deploy all eda-server related components.
5+
6+
Pre-requisites
7+
--------------
8+
9+
Minikube - https://minikube.sigs.k8s.io/docs ( `minikube addons enable storage-provisioner` and `minikube addons enable default-storageclass` )
10+
11+
Red Hat OpenShift Local - https://developers.redhat.com/products/openshift-local/overview
12+
13+
14+
Ansible - https://github.com/ansible/ansible
15+
16+
Kubernetes Collection for Ansible - `ansible-galaxy collection install kubernetes.core`
17+
18+
19+
Usage
20+
--------------
21+
22+
Make sure that your Minikube or Openshift Local is running.
23+
24+
After that, review the variables and make any necessary customizations. This can be done in the file:
25+
26+
```bash
27+
group_vars/all/vars.yml
28+
```
29+
30+
The following variables can be customized to determine whether a specific action is executed or not.
31+
32+
**env_type**: This variable supports `"minikube"` or `"openshift"` as the execution target.
33+
34+
**eda_deploy_operator**: This variable must be set to `"true"` for the eda-server-operator to be installed.
35+
36+
**eda_deploy_server**: This variable must be set to `"true"` for eda-server to be installed. At this moment, this installation still relies on the eda-server-operator, as everything is based on the "eda" crd.
37+
38+
39+
To run, simply be in the same directory as the `playbook.yaml` file and execute the command: `ansible-playbook playbook.yaml`
40+
41+
42+
At the end of the execution, you should have all components installed in the namespace defined in the variable `eda_namespace`
43+
44+
Attention Points
45+
----------------
46+
47+
For execution on Openshift, the variable `postgres_storage_class` should be updated
48+

automation/ansible.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[defaults]
2+
host_key_checking = False
3+
retry_files_enabled = False
4+
callback_whitelist = profile_tasks
5+
6+
[ssh_connection]
7+
ssh_args = -o ControlMaster=auto -o ControlPersist=600s
8+
pipelining = True

automation/group_vars/all/vars.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
ansible_python_interpreter: /usr/bin/python3
3+
4+
env_type: minikube #minikube #openshift
5+
eda_deploy_operator: "true"
6+
eda_deploy_server: "true"
7+
8+
eda_namespace: aap-eda
9+
10+
eda_operator:
11+
api_version: kustomize.config.k8s.io/v1beta1
12+
namespace: aap-eda
13+
disable_name_suffix_hash: true
14+
secret_generator_name: redhat-operators-pull-secret
15+
operator_literal: eda
16+
resource_url: github.com/ansible/eda-server-operator/config/default?ref=0.0.11
17+
image_name: quay.io/ansible/eda-server-operator
18+
image_new_tag: 0.0.11
19+
20+
eda_operator_files_path: roles/eda-deploy-operator/files
21+
eda_server_files_path: roles/eda-deploy-server/files
22+
23+
eda_server:
24+
pvc_name: eda-postgres-13-volume
25+
access_modes: ReadWriteOnce
26+
storage_request: 500Mi
27+
namespace: aap-eda
28+
29+
admin_user: admin
30+
admin_password_secret: eda-admin-password
31+
32+
ingress_type: ingress
33+
ingress_class_name: nginx
34+
hostname: eda.local
35+
36+
automation_server_url: https://awx.local
37+
automation_server_ssl_verify: "no"
38+
39+
image: quay.io/ansible/eda-server
40+
image_version: sha-98eaec9
41+
42+
image_web: quay.io/ansible/eda-ui
43+
image_web_version: 2.4.860
44+
45+
redis_image:
46+
redis_image_version:
47+
48+
api:
49+
replicas: 1
50+
51+
ui:
52+
replicas: 1
53+
54+
worker:
55+
replicas: 2
56+
57+
redis:
58+
replicas: 1
59+
60+
database:
61+
database_secret: eda-database-configuration
62+
#postgres_storage_class: crc-csi-hostpath-provisioner # openshift
63+
postgres_storage_class: standard # minishift
64+
storage_requirements:
65+
requests:
66+
storage: 3Gi
67+
resource_requirements:
68+
requests: {}
69+
70+
eda_server_kustomization:
71+
eda_database_configuration_host: eda-postgres-13
72+
eda_database_configuration_port: 5432
73+
eda_database_configuration_database: eda
74+
eda_database_configuration_username: eda
75+
eda_database_configuration_password: testpass
76+
eda_database_configuration_type: managed
77+
eda_admin_password_password: testpass

automation/hosts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[all]
2+
localhost

automation/playbook.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- hosts: localhost
2+
roles:
3+
4+
- name: eda-deploy-operator
5+
when: (env_type == "minikube" or env_type == "openshift") and eda_deploy_operator == "true"
6+
7+
- name: eda-deploy-server
8+
when: (env_type == "minikube" or env_type == "openshift") and eda_deploy_server == "true"

automation/roles/eda-deploy-operator/files/.gitkeep

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: Check {{ env_type }} connection
3+
block:
4+
- k8s_info:
5+
api_version: v1
6+
kind: Pod
7+
namespace: default
8+
name: ansible-check-pod
9+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
10+
register: k8s_info_result
11+
rescue:
12+
- fail:
13+
msg: "Failed to connect to Kubernetes cluster. Please check your configuration and try again."
14+
always:
15+
- debug:
16+
var: k8s_info_result
17+
18+
- name: Create {{ eda_namespace }} namespace
19+
k8s:
20+
definition:
21+
apiVersion: v1
22+
kind: Namespace
23+
metadata:
24+
name: "{{ eda_namespace }}"
25+
when: k8s_info_result is succeeded
26+
27+
- name: Generate EDA Operator kustomization file
28+
template:
29+
src: kustomization-eda-operator.yaml.j2
30+
dest: "{{ eda_operator_files_path }}/kustomization.yaml"
31+
32+
- name: Apply EDA Operator kustomization file
33+
k8s:
34+
definition: "{{ lookup('pipe', 'kustomize build {{ eda_operator_files_path }}') }}"
35+
state: present
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: {{ eda_operator.api_version }}
2+
kind: Kustomization
3+
namespace: {{ eda_operator.namespace }}
4+
5+
generatorOptions:
6+
disableNameSuffixHash: {{ eda_operator.disable_name_suffix_hash }}
7+
8+
secretGenerator:
9+
- name: {{ eda_operator.secret_generator_name }}
10+
literals:
11+
- operator={{ eda_operator.operator_literal }}
12+
13+
resources:
14+
- {{ eda_operator.resource_url }}
15+
16+
images:
17+
- name: {{ eda_operator.image_name }}
18+
newTag: {{ eda_operator.image_new_tag }}

automation/roles/eda-deploy-server/files/.gitkeep

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
- name: Check {{ env_type }} connection
3+
block:
4+
- k8s_info:
5+
api_version: v1
6+
kind: Pod
7+
namespace: default
8+
name: ansible-check-pod
9+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
10+
register: k8s_info_result
11+
rescue:
12+
- fail:
13+
msg: "Failed to connect to Kubernetes cluster. Please check your configuration and try again."
14+
always:
15+
- debug:
16+
var: k8s_info_result
17+
18+
- name: Check if {{ eda_namespace }} namespace exists
19+
k8s_info:
20+
kind: Namespace
21+
name: "{{ eda_namespace }}"
22+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
23+
register: namespace_info
24+
failed_when: namespace_info.resources|length == 0
25+
26+
- name: Generate EDA Server pvc file
27+
template:
28+
src: eda-server-pvc.yaml.j2
29+
dest: "{{ eda_server_files_path }}/eda-server-pvc.yaml"
30+
31+
- name: Generate EDA Server file
32+
template:
33+
src: eda-server.yaml.j2
34+
dest: "{{ eda_server_files_path }}/eda-server.yaml"
35+
36+
- name: Generate EDA Server kustomization file
37+
template:
38+
src: eda-server-kustomization.yaml.j2
39+
dest: "{{ eda_server_files_path }}/kustomization.yaml"
40+
41+
- name: Apply EDA Server kustomization file
42+
k8s:
43+
definition: "{{ lookup('pipe', 'kustomize build {{ eda_server_files_path }}') }}"
44+
state: present
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
namespace: {{ eda_namespace }}
5+
6+
generatorOptions:
7+
disableNameSuffixHash: true
8+
9+
secretGenerator:
10+
- name: eda-database-configuration
11+
type: Opaque
12+
literals:
13+
- host={{ eda_server_kustomization.eda_database_configuration_host }}
14+
- port={{ eda_server_kustomization.eda_database_configuration_port }}
15+
- database={{ eda_server_kustomization.eda_database_configuration_database }}
16+
- username={{ eda_server_kustomization.eda_database_configuration_username }}
17+
- password={{ eda_server_kustomization.eda_database_configuration_password }}
18+
- type=managed
19+
20+
- name: eda-admin-password
21+
type: Opaque
22+
literals:
23+
- password={{ eda_server_kustomization.eda_admin_password_password }}
24+
25+
resources:
26+
- eda-server-pvc.yaml
27+
- eda-server.yaml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: {{ eda_server.pvc_name }}
5+
namespace: {{ eda_server.namespace }}
6+
spec:
7+
accessModes:
8+
- "{{ eda_server.access_modes }}"
9+
resources:
10+
requests:
11+
storage: {{ eda_server.storage_request }}
12+
status: {}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: eda.ansible.com/v1alpha1
2+
kind: EDA
3+
metadata:
4+
name: eda
5+
spec:
6+
admin_user: {{ eda_server.admin_user }}
7+
admin_password_secret: {{ eda_server.admin_password_secret }}
8+
9+
ingress_type: {{ eda_server.ingress_type }}
10+
ingress_class_name: {{ eda_server.ingress_class_name }}
11+
hostname: {{ eda_server.hostname }}
12+
13+
automation_server_url: {{ eda_server.automation_server_url }}
14+
automation_server_ssl_verify: {{ eda_server.automation_server_ssl_verify }}
15+
16+
image: {{ eda_server.image }}
17+
image_version: {{ eda_server.image_version }}
18+
19+
image_web: {{ eda_server.image_web }}
20+
image_web_version: {{ eda_server.image_web_version }}
21+
22+
api:
23+
replicas: {{ eda_server.api.replicas }}
24+
resource_requirements:
25+
requests: {}
26+
ui:
27+
replicas: {{ eda_server.ui.replicas }}
28+
resource_requirements:
29+
requests: {}
30+
worker:
31+
replicas: {{ eda_server.worker.replicas }}
32+
resource_requirements:
33+
requests: {}
34+
redis:
35+
replicas: {{ eda_server.redis.replicas }}
36+
resource_requirements:
37+
requests: {}
38+
database:
39+
database_secret: {{ eda_server.database.database_secret }}
40+
postgres_storage_class: {{ eda_server.database.postgres_storage_class }}
41+
storage_requirements:
42+
requests:
43+
storage: {{ eda_server.database.storage_requirements.requests.storage }}
44+
resource_requirements:
45+
requests: {}

automation/roles/requirements.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
collections:
3+
- name: kubernetes.core
4+
version: 3.0.0

0 commit comments

Comments
 (0)