Wolfgang Kulhanek
2020-03-05 b3826b16032c10241404d3c8c322871fbebc26f8
Camel K and CRW Workload Verification (#1238)

* first start

* added users to appropriate projects

* got users for che working

* crw update

* added kamel stuff

* finished workload

* camel k operator installing

* apicurio operator working

* back to working

* added sample vars

* docker stuff

* fully working

* added env variable for kubeconfig

* updated readme

* added crw startup extra

* updates to stack image 1.2 for updated kamel tools

* verification workload
1 files added
7 files modified
158 ■■■■■ changed files
ansible/roles/ocp4-workload-camelk-crw/defaults/main.yml 3 ●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/files/stack.Dockerfile 8 ●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/files/stack_imagestream.yaml 2 ●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/tasks/pre_workload.yml 9 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/tasks/verify_workload.yml 125 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/tasks/workload_per_project_camelk.yml 8 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/tasks/workload_per_project_codereadyworkspaces.yml 1 ●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/tasks/workload_project.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-camelk-crw/defaults/main.yml
@@ -18,7 +18,8 @@
#_kogito_csv_version: kogito-operator.v0.7.0
_prometheus_csv_version: prometheusoperator.0.32.0
_apicurio_csv_version: apicuritooperator.v0.1.0
camelk_version: 1.0.0-rc1
_camelk_csv_version: camel-k-operator.v1.0.0-rc2
camelk_version: 1.0.0-rc2
apicurito_template_file: apicurito.yaml.j2
_account_name: gitadmin
ansible/roles/ocp4-workload-camelk-crw/files/stack.Dockerfile
@@ -6,14 +6,14 @@
# RH_PASSWORD=your-password
#
# then:
# DOCKER_BUILDKIT=1 docker build --progress=plain --secret id=rhsm,src=rhsm.secret.yaml -t quay.io/username/cloudnative-workspaces-kamel:VVV -f stack.Dockerfile .
# docker push quay.io/username/quay.io/username/cloudnative-workspaces-kamel:VVVV
# DOCKER_BUILDKIT=1 docker build --progress=plain --secret id=rhsm,src=rhsm.secret.yaml -t quay.io/mcochran/cloudnative-workspaces-kamel:VVV -f stack.Dockerfile .
# docker push quay.io/mcochran/quay.io/mcochran/cloudnative-workspaces-kamel:VVVV
FROM registry.redhat.io/codeready-workspaces/stacks-java-rhel8:2.0
ENV GRAALVM_VERSION=19.3.1
ENV QUARKUS_VERSION=1.2.0.Final
ENV CAMELK_VERSION=1.0.0-RC1
ENV CAMELK_VERSION=1.0.0-RC2
ENV MVN_VERSION=3.6.3
ENV GRAALVM_HOME="/usr/local/graalvm-ce-java8-${GRAALVM_VERSION}"
ENV MAVEN_OPTS="-Xmx4G -Xss128M -XX:MetaspaceSize=1G -XX:MaxMetaspaceSize=2G -XX:+CMSClassUnloadingEnabled"
@@ -30,7 +30,7 @@
RUN wget -O /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/graalvm-ce-java8-linux-amd64-${GRAALVM_VERSION}.tar.gz && cd /usr/local && tar -xvzf /tmp/graalvm.tar.gz && rm -rf /tmp/graalvm.tar.gz && ${GRAALVM_HOME}/bin/gu install native-image
RUN wget -O /tmp/kamel.tar.gz https://github.com/apache/camel-k/releases/download/1.0.0-RC1/camel-k-client-1.0.0-RC1-linux-64bit.tar.gz && cd /usr/bin && tar -xvzf /tmp/kamel.tar.gz && chmod a+x /usr/bin/kamel && rm -f /tmp/kamel.tar.gz
RUN wget -O /tmp/kamel.tar.gz https://github.com/apache/camel-k/releases/download/1.0.0-RC2/camel-k-client-1.0.0-RC2-linux-64bit.tar.gz && cd /usr/bin && tar -xvzf /tmp/kamel.tar.gz && chmod a+x /usr/bin/kamel && rm -f /tmp/kamel.tar.gz
RUN wget -O /tmp/mvn.tar.gz https://www-us.apache.org/dist/maven/maven-3/${MVN_VERSION}/binaries/apache-maven-${MVN_VERSION}-bin.tar.gz && tar xzf /tmp/mvn.tar.gz && rm -rf /tmp/mvn.tar.gz && mkdir /usr/local/maven && mv apache-maven-${MVN_VERSION}/ /usr/local/maven/ && alternatives --install /usr/bin/mvn mvn /usr/local/maven/apache-maven-${MVN_VERSION}/bin/mvn 1
ansible/roles/ocp4-workload-camelk-crw/files/stack_imagestream.yaml
@@ -14,5 +14,5 @@
      version: "1.0"
    from:
      kind: DockerImage
      name: quay.io/mcochran/cloudnative-workspaces-kamel:1.1
      name: quay.io/mcochran/cloudnative-workspaces-kamel:1.2
    name: "1.0"
ansible/roles/ocp4-workload-camelk-crw/tasks/pre_workload.yml
@@ -41,6 +41,15 @@
    src: templates
    dest: "{{ tmp_dir }}"
- name: extract route_subdomain
  k8s_facts:
    kind: Ingress
  register: route_subdomain_r
- name: set the route
  set_fact:
    route_subdomain: "{{ route_subdomain_r.resources[0].spec.domain | trim }}"
# Leave this as the last task in the playbook.
- name: pre_workload tasks complete
  debug:
ansible/roles/ocp4-workload-camelk-crw/tasks/verify_workload.yml
New file
@@ -0,0 +1,125 @@
- name: verify user project exists
  k8s_facts:
    api_version: v1
    kind: Namespace
    name: "{{ _namespace }}"
    field_selectors:
      - status.phase=Active
  register: r_user_namespace
  failed_when: r_user_namespace.resources | list | length != 1
- name: verify codeready pod is running
  k8s_facts:
    api_version: v1
    kind: Pod
    namespace: "{{ _namespace }}"
    label_selectors:
      - app=codeready
      - component=codeready
    field_selectors:
      - status.phase=Running
  register: r_codeready_pod
  failed_when: r_codeready_pod.resources | list | length != 1
- name: verify codeready is accessible
  uri:
    url: http://codeready-{{ _namespace }}.{{ route_subdomain }}
    method: GET
    status_code: 200
- name: verify grafana pod is running
  k8s_facts:
    api_version: v1
    kind: Pod
    namespace: "{{ _namespace }}"
    label_selectors:
      - app=grafana
    field_selectors:
      - status.phase=Running
  register: r_grafana_pod
  failed_when: r_grafana_pod.resources | list | length != 1
- name: verify grafana is accessible
  uri:
    url: https://grafana-route-{{ _namespace }}.{{ route_subdomain }}
    method: GET
    status_code: -1
# expects -1 due to ssl being needed
- name: verify apicurito pod is running
  k8s_facts:
    api_version: v1
    kind: Pod
    namespace: "{{ _namespace }}"
    label_selectors:
      - app=apicurito
      - apicurito_cr=apicurito-service
    field_selectors:
      - status.phase=Running
  register: r_apicurito_pod
  failed_when: r_apicurito_pod.resources | list | length < 1
- name: verify apicurito is accessible
  uri:
    url: http://apicurito-service-{{ _namespace }}.{{ route_subdomain }}
    method: GET
    status_code: 200
- name: verify keycloak pod is running
  k8s_facts:
    api_version: v1
    kind: Pod
    namespace: "{{ _namespace }}"
    label_selectors:
      - app=codeready
      - component=keycloak
    field_selectors:
      - status.phase=Running
  register: r_keycloak_pod
  failed_when: r_keycloak_pod.resources | list | length != 1
- name: verify keycloak is accessible
  uri:
    url: http://keycloak-{{ _namespace }}.{{ route_subdomain }}
    method: GET
    status_code: 200
- name: verify prometheus pod is running
  k8s_facts:
    api_version: v1
    kind: Pod
    namespace: "{{ _namespace }}"
    label_selectors:
      - app=prometheus
    field_selectors:
      - status.phase=Running
  register: r_prometheus_pod
  failed_when: r_prometheus_pod.resources | list | length < 1
- name: verify prometheus is accessible
  uri:
    url: http://prometheus-prom-{{ _namespace }}.{{ route_subdomain }}
    method: GET
    status_code: -1
# expects -1 due to ssl being needed
- name: verify Camel K operator pod is running
  k8s_facts:
    api_version: v1
    kind: Pod
    namespace: "{{ _namespace }}"
    label_selectors:
      - app=camel-k
    field_selectors:
      - status.phase=Running
  register: r_camelk_operator_pod
  failed_when: r_camelk_operator_pod.resources | list | length != 1
- name: verify Camel K integration platform is running
  k8s_facts:
    api_version: v1
    kind: IntegrationPlatform
    namespace: "{{ _namespace }}"
  register: r_camelk_platform
  failed_when: r_camelk_platform | length < 0
ansible/roles/ocp4-workload-camelk-crw/tasks/workload_per_project_camelk.yml
@@ -15,6 +15,14 @@
    state: present
    resource_definition: "{{ lookup('template', 'camelk-subscription.yaml.j2') }}"
- name: Wait until csv/{{ _camelk_csv_version }} is Succeeded
  command: >
    oc get csv/{{ _camelk_csv_version }} -o jsonpath='{.status.phase}' -n "{{ _namespace }}"
  register: camelcsv
  retries: "{{ _retry }}"
  delay: "{{ _delay }}"
  until: camelcsv.stdout == "Succeeded"
- name: Create Camel Integration Platform for Project
  k8s:
    state: present
ansible/roles/ocp4-workload-camelk-crw/tasks/workload_per_project_codereadyworkspaces.yml
@@ -136,7 +136,6 @@
  register: r_stack_is
  retries: 200
  delay: 10
  ignore_errors: yes
  until: r_stack_is.resources | list | length == 1
- name: import stack image
ansible/roles/ocp4-workload-camelk-crw/tasks/workload_project.yml
@@ -37,3 +37,5 @@
- name: Give access to namespace for {{ _namespace }}
  shell: "oc policy add-role-to-user admin {{ namespace_prefix }}{{ user_num }} -n {{ _namespace }}"
- name: Verify everything is deployed correctly for {{ _namespace }}
  include_tasks: verify_workload.yml