Skip to content

Commit

Permalink
Merge pull request #895 from IBM/deployer-mac
Browse files Browse the repository at this point in the history
CP4D 4.8.8 & Mac deployment
  • Loading branch information
fketelaars authored Jan 31, 2025
2 parents 57cd5c6 + af692da commit f44c9a6
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,24 @@
head -1 {{ _cp4d_get_cr_status_file }}
register: _csv_column_headers_output

# The header in CP4D 4.8 is: Component,CR-kind,CR-name,Namespace,Status,Version,Creationtimestamp,Reconciled-version,Operator-info
# The header in CP4D 5.1 is: Components,CR Kind,CR Name,Creation Timestamp,Namespace,Expected Version,Reconciled Version,Operator Information,Progress,Progress Message,Reconcile History,Status
# Between CP4D 5.1.0 and 5.1.1, the Component column has been renamed to Components
- debug:
var: _csv_column_headers_output.stdout

- set_fact:
_csv_column_headers: "{{ _csv_column_headers_output.stdout | replace('Component,','Components,') | replace(' ','_') }}"
_csv_column_headers: >-
{{ _csv_column_headers_output.stdout
| replace('Component,','Components,')
| replace('CR-kind','CR_Kind')
| replace('CR-name','CR_Name')
| replace(',Version,',',Expected_Version,')
| replace('Creationtimestamp','Creation_Timestamp')
| replace('Reconciled-version','Reconciled_Version')
| replace('Operator-info','Operator_Information')
| replace(' ','_')
| replace('-','_') }}
# Try to copy the get-cr-status output file. In certain situations (Windows, SELinux), the command may fail and has to be re-run without remote_src
- block:
Expand All @@ -79,6 +94,3 @@
fieldnames: "{{ _csv_column_headers }}"
skipinitialspace: True
register: _get_cr_status_json

- debug:
var: _get_cr_status_json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Login to the OpenShift cluster {{ _current_openshift_cluster.name }}
include_role:
name: openshift-login
vars:
_p_openshift_cluster_name: "{{ _current_openshift_cluster.name }}"

- name: Output OpenShift URLs and passwords
include_tasks: openshift-show-details.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: Get kubeadmin password {rom the vault
include_role:
name: vault-get-secret
vars:
secret_name: "{{ _current_openshift_cluster.name }}-kubeadmin-password"
secret_group: "{{ environment_name }}"
_p_secret_variable: _kubeadmin_password

- name: Get oc-login secret
include_role:
name: vault-get-secret
vars:
secret_name: oc-login
secret_group: "{{ environment_name }}"
_p_secret_variable: _oc_login_secret

- name: Get OpenShift Console endpoint
shell: |
oc whoami --show-console
register: _openshift_console_endpoint

- name: Get OpenShift API endpoint
shell: |
oc whoami --show-server
register: _openshift_api_endpoint

- name: Make sure that directory {{ status_dir }}/cloud-paks exists
file:
path: "{{ status_dir }}/cloud-paks"
state: directory

- name: Write Cloud Pak for Data info to {{ status_dir }}/cloud-paks/cloud-pak-deployer-info.txt
blockinfile:
path: "{{ status_dir }}/cloud-paks/cloud-pak-deployer-info.txt"
create: True
insertafter: EOF
marker: ""
block: |
{{ lookup('template','openshift-details.j2') }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- OpenShift cluster {{ _current_openshift_cluster.name }} ---
OpenShift Console URL: {{ _openshift_console_endpoint.stdout }}
OpenShift API endpoint: {{ _openshift_api_endpoint.stdout }}
{% if _kubeadmin_password | default('') != '' %}
kubeadmin password: {{ _kubeadmin_password }}
{% endif %}
{% if _oc_login_secret | default('') != '' %}
OpenShift login: {{ _oc_login_secret }}
{% endif %}
32 changes: 24 additions & 8 deletions cp-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ run_env_logs() {
fi
fi
fi

# Show login info
if [ -e ${STATUS_DIR}/cloud-paks/cloud-pak-deployer-info.txt ];then
cat ${STATUS_DIR}/cloud-paks/cloud-pak-deployer-info.txt
fi
}

# --------------------------------------------------------------------------------------------------------- #
Expand Down Expand Up @@ -630,23 +635,30 @@ if [ "${ARCH}" == "amd64" ];then
ARCH="x86_64"
fi

# Determine architecture of the image
if [[ "${ARCH}" == "x86_64" || "${ARCH}" == "arm64" ]]; then
IMAGE_ARCH="amd64"
else
IMAGE_ARCH=${ARCH}
fi

# If images have not been overridden, set the variables here
if [ -z $CPD_OLM_UTILS_V2_IMAGE ];then
if [ "${ARCH}" == "x86_64" ]; then
if [[ "${IMAGE_ARCH}" == "amd64" || "${IMAGE_ARCH}" == "arm64" ]]; then
export CPD_OLM_UTILS_V2_IMAGE=icr.io/cpopen/cpd/olm-utils-v2:latest
else
export CPD_OLM_UTILS_V2_IMAGE=icr.io/cpopen/cpd/olm-utils-v2:latest.$ARCH
export CPD_OLM_UTILS_V2_IMAGE=icr.io/cpopen/cpd/olm-utils-v2:latest.${IMAGE_ARCH}
fi
else
echo "Custom olm-utils-v2 image ${CPD_OLM_UTILS_V2_IMAGE} will be used."
fi

# If images have not been overridden, set the variables here
if [ -z $CPD_OLM_UTILS_V3_IMAGE ];then
if [ "${ARCH}" == "x86_64" ]; then
if [[ "${IMAGE_ARCH}" == "amd64" || "${ARCH}" == "arm64" ]]; then
export CPD_OLM_UTILS_V3_IMAGE=icr.io/cpopen/cpd/olm-utils-v3:latest
else
export CPD_OLM_UTILS_V3_IMAGE=icr.io/cpopen/cpd/olm-utils-v3:latest.$ARCH
export CPD_OLM_UTILS_V3_IMAGE=icr.io/cpopen/cpd/olm-utils-v3:latest.${IMAGE_ARCH}
fi
else
echo "Custom olm-utils-v3 image ${CPD_OLM_UTILS_V3_IMAGE} will be used."
Expand Down Expand Up @@ -685,16 +697,17 @@ if ! $INSIDE_CONTAINER;then
# Show version info
cat ${SCRIPT_DIR}/.version-info/version-info.sh
# Build the image
if [ "${ARCH}" == "x86_64" ]; then
if [ "${IMAGE_ARCH}" == "amd64" ]; then
DOCKERFILE=Dockerfile
else
DOCKERFILE=Dockerfile.${ARCH}
DOCKERFILE=Dockerfile.${IMAGE_ARCH}
fi
${CPD_CONTAINER_ENGINE} build -t cloud-pak-deployer:${CPD_IMAGE_TAG} \
--pull \
-f ${SCRIPT_DIR}/${DOCKERFILE} \
--build-arg CPD_OLM_UTILS_V2_IMAGE=${CPD_OLM_UTILS_V2_IMAGE} \
--build-arg CPD_OLM_UTILS_V3_IMAGE=${CPD_OLM_UTILS_V3_IMAGE} \
--platform linux/${IMAGE_ARCH} \
${SCRIPT_DIR}
exit $?
fi
Expand Down Expand Up @@ -967,6 +980,8 @@ fi
if ! $INSIDE_CONTAINER;then
run_cmd="${CPD_CONTAINER_ENGINE} run"

run_cmd+=" --arch ${IMAGE_ARCH}"

# If CPD_CONTAINER_NAME has been specified, give the container this name
if [ ! -z $CPD_CONTAINER_NAME ];then
run_cmd+=" --name ${CPD_CONTAINER_NAME}"
Expand Down Expand Up @@ -1092,9 +1107,9 @@ if ! $INSIDE_CONTAINER;then
else
run_cmd+=" --entrypoint /cloud-pak-deployer/docker-scripts/run_automation.sh"
fi
run_cmd+=" cloud-pak-deployer:${CPD_IMAGE_TAG}"
run_cmd+=" localhost/cloud-pak-deployer:${CPD_IMAGE_TAG}"

# echo $run_cmd
# echo $run_cmd

# If running "environment" subcommand with apply/destroy, follow log
if [ "$SUBCOMMAND" == "environment" ] && [[ "${ACTION}" == "apply" || "${ACTION}" == "destroy" || "${ACTION}" == "wizard" || "${ACTION}" == "download" ]];then
Expand All @@ -1110,6 +1125,7 @@ if ! $INSIDE_CONTAINER;then
else
PODMAN_EXIT_CODE=$(${CPD_CONTAINER_ENGINE} inspect ${CURRENT_CONTAINER_ID} --format='{{.State.ExitCode}}')
fi

else
eval $run_cmd
PODMAN_EXIT_CODE=$?
Expand Down
3 changes: 3 additions & 0 deletions docs/src/05-install/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

To install and run the Cloud Pak Deployer, ensure that either podman or docker is available on your system. These are typically available on various Linux distributions such as Red Hat Enterprise Linux (preferred), Fedora, CentOS, Ubuntu, and MacOS. Note that Docker behaves differently on Windows compared to Linux platforms, potentially causing deployment issues.

!!! info
If you plan to run Cloud Pak Deployer from the OpenShift console, you can skip these steps. A Cloud Pak Deployer container image is already available on quay.io, to be used in an OpenShift job.

### Using a Windows workstation

If you're working on a Windows workstation without access to a Linux server, you can use VirtualBox to create a Linux virtual machine for deployment.
Expand Down
64 changes: 63 additions & 1 deletion docs/src/10-use-deployer/3-run/existing-openshift-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ data:
cartridges:
- name: cp-foundation
license_service:
state: disabled
threads_per_core: 2
- name: lite
Expand Down Expand Up @@ -568,6 +567,69 @@ spec:
!!! info
When running the deployer installing Cloud Pak for Data, the first run will fail. This is because the deployer applies the node configuration to OpenShift, which will cause all nodes to restart one by one, including the node that runs the deployer. Because of the Job setting, a new deployer pod will automatically start and resume from where it was stopped.

## Finishing up

Once the process has finished, it will output the URLs by which you can access the deployed Cloud Pak.
```
--- Cloud Pak for Data project cpd ---
CP4D URL: https://cpd-cpd.apps.6759f8089266ae8f450d554f.ocp.techzone.ibm.com
CP4D User: cpadmin
CP4D cpadmin password: <your-cpadmin-password>
```

You can also find this information under the `cloud-paks` directory in the status directory you specified. The following commands can be run from the **debug** pod terminal that is in the `cloud-pak-deployer` project.

To retrieve the Cloud Pak URL(s):

``` { .bash .copy }
cat $STATUS_DIR/cloud-paks/*
```

This will show the Cloud Pak URLs:

```output
Cloud Pak for Data URL for cluster pluto-01 and project cpd (domain name specified was example.com):
https://cpd-cpd.apps.pluto-01.example.com
```

The `admin` password can be retrieved from the vault as follows:

List the secrets in the vault:

``` { .bash .copy }
cp-deploy.sh vault list
```

This will show something similar to the following:

```output
Secret list for group sample:
- ibm_cp_entitlement_key
- oc-login
- cp4d_admin_cpd_demo
```

You can then retrieve the Cloud Pak for Data admin password like this:

``` { .bash .copy }
cp-deploy.sh vault get --vault-secret cp4d_admin_cpd_sample
```

```output
PLAY [Secrets] *****************************************************************
included: /cloud-pak-deployer/automation-roles/99-generic/vault/vault-get-secret/tasks/get-secret-file.yml for localhost
cp4d_admin_zen_sample_sample: gelGKrcgaLatBsnAdMEbmLwGr
```


Once the process has finished, it will output the URLs by which you can access the deployed Cloud Pak.
```
--- Cloud Pak for Data project cpd ---
CP4D URL: https://cpd-cpd.apps.6759f8089266ae8f450d554f.ocp.techzone.ibm.com
CP4D User: cpadmin
CP4D cpadmin password: <your-cpadmin-password>
```

## Re-run deployer when failed or if you want to update the configuration
If the deployer has failed or if you want to make changes to the configuration after the successful run, you can do the following:

Expand Down
10 changes: 9 additions & 1 deletion docs/src/10-use-deployer/3-run/existing-openshift.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,15 @@ If the Cloud Pak Deployer fails, for example because certain infrastructure comp

### Finishing up

Once the process has finished, it will output the URLs by which you can access the deployed Cloud Pak. You can also find this information under the `cloud-paks` directory in the status directory you specified.
Once the process has finished, it will output the URLs by which you can access the deployed Cloud Pak.
```
--- Cloud Pak for Data project cpd ---
CP4D URL: https://cpd-cpd.apps.6759f8089266ae8f450d554f.ocp.techzone.ibm.com
CP4D User: cpadmin
CP4D cpadmin password: <your-cpadmin-password>
```

You can also find this information under the `cloud-paks` directory in the status directory you specified.

To retrieve the Cloud Pak URL(s):

Expand Down
7 changes: 7 additions & 0 deletions playbooks/playbook-env-apply-80-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
path: "{{ status_dir }}/cloud-paks/cloud-pak-deployer-info.txt"
state: touch

- name: OpenShift smoke tests
include_role:
name: openshift-smoke-tests
loop: "{{ all_config.openshift | default([]) }}"
loop_control:
loop_var: _current_openshift_cluster

- name: OpenShift Red Hat SSO smoke tests
include_role:
name: openshift-redhat-sso-smoke-tests
Expand Down

0 comments on commit f44c9a6

Please sign in to comment.