Diego Alejandro Torres Fuerte
2020-02-03 0ed4e2840fc6c03287dfee187066fa1c96efb15b
Dmf75 (#1087)

* RHDM foundations AAD migration

* Fix angular deployment
1 files added
2 files modified
267 ■■■■■ changed files
ansible/roles/ocp-workload-bxms-dm-foundations/defaults/main.yml 11 ●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-bxms-dm-foundations/tasks/workload.yml 13 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-bxms-dm-foundations/templates/ng-dmf-template.yaml 243 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-bxms-dm-foundations/defaults/main.yml
@@ -34,18 +34,13 @@
default_min_cpu: 250m
default_max_cpu: 1000m
#DM_IS_URL: https://raw.githubusercontent.com/jboss-container-images/rhdm-7-openshift-image/7.1.1.GA/rhdm71-image-streams.yaml
DM_IS_FILE_NAME: "rhdm71-image-streams.yaml"
DM_IS_URL: "/tmp/{{DM_IS_FILE_NAME}}"
SECRETS_TEMPLATE_URL: https://raw.githubusercontent.com/jboss-container-images/rhdm-7-openshift-image/7.5.1.GA/example-app-secret-template.yaml
# DM_TEMPLATE_URL: https://raw.githubusercontent.com/gpe-mw-training/bxms_decision_mgmt_foundations_lab/master/resources/rhdm7-full-ng.yaml
DM_TEMPLATE_URL: https://raw.githubusercontent.com/gpe-mw-training/bxms_decision_mgmt_foundations_lab/master/resources/rhdm7-only.yaml
NG_TEMPLATE_URL: https://raw.githubusercontent.com/gpe-mw-training/gpte-ng-dmf/master/ng-dmf-template.yaml
ocp_apps_domain: apps.{{subdomain_base}}
angular_image: quay.io/rhtgptetraining/dmf-angular:1.4
angular_image_namespace: openshift
kieserver_image: quay.io/rhtgptetraining/rhdm_ks:1.1
decisioncentral_image: quay.io/rhtgptetraining/rhdm_dc:1.0
kieserver_image_namespace: openshift
ansible/roles/ocp-workload-bxms-dm-foundations/tasks/workload.yml
@@ -19,6 +19,7 @@
  block:
    - command: "oc import-image {{kieserver_image}} -n {{ kieserver_image_namespace }} --confirm"
    - command: "oc import-image {{decisioncentral_image}} -n {{ decisioncentral_image_namespace }} --confirm"
    - command: "oc import-image {{angular_image}} -n {{ angular_image_namespace }} --confirm"
# Note; depending on the environment, OCP projects may or may not have default limit ranges
- name: Delete default limitrange
@@ -34,14 +35,16 @@
    oc create -f /tmp/{{guid}}/{{ocp_project}}_limitrange.yaml -n {{ocp_project}}
- name: Create the Angular Application Template
  shell: oc create -f {{NG_TEMPLATE_URL}} -n {{ocp_project}}
  template:
    src: "templates/ng-dmf-template.yaml"
    dest: "/tmp/{{ guid }}/ng-dmf-template.yaml"
  changed_when: false
- name: Fire and forget to install Angular application container
  async: 3600
  poll: 0
  shell: |
      oc new-app --template=ng-dmf-template --name=angular-dmf -n {{ocp_project}} \
      -p APPLICATION_NAME=angular-dmf > /tmp/{{guid}}/angular-dmf.txt
      oc new-app -f /tmp/{{ guid }}/ng-dmf-template.yaml -n {{ ocp_project }} -p APPLICATION_NAME=angular-dmf
- name: Initialize secrets template
  shell: "oc create -f {{SECRETS_TEMPLATE_URL}} -n {{ocp_project}}"
@@ -102,8 +105,8 @@
- include_tasks: ./wait_for_deploy.yml
  vars:
    build_to_wait:
      - angular-dmf-ng-dmf
    pod_to_wait:
      - angular-dmf-ng-dmfundertow
- name: Give ocp_username access to ocp_project; user = {{ocp_username}}
  shell: "oc policy add-role-to-user admin {{ocp_username}} -n {{ocp_project}}"
ansible/roles/ocp-workload-bxms-dm-foundations/templates/ng-dmf-template.yaml
New file
@@ -0,0 +1,243 @@
---
kind: Template
apiVersion: v1
metadata:
  annotations:
    iconClass: icon-jboss
    tags: rhdm,angujar,nodejs
    version: "4.0"
    openshift.io/display-name: Angular JS Application to interact with Red Hat Decision Manager 7.1
    openshift.io/provider-display-name: Red Hat, Inc. - GPTE
    description: Angular JS Application to interact with Red Hat Decision Manager 7 Created with education purposes of foundational course
    template.openshift.io/long-description: Angular JS Application to interact with Red Hat Decision Manager 7 Created with education purposes of foundational course
    template.openshift.io/documentation-url: https://access.redhat.com/documentation/en-us/red_hat_decision_manager/7.1/html/deploying_a_red_hat_decision_manager_7.1_authoring_environment_on_red_hat_openshift_container_platform/
    template.openshift.io/support-url: https://access.redhat.com
    template.openshift.io/bindable: "false"
  name: ng-dmf-template
labels:
  template: ng-dmf-template
  rhdm: "7.6"
message: |-
          A new angular application to interact with RHDM7.6 Has been created.
parameters:
- displayName: Application Name
  description: The name for the application.
  name: APPLICATION_NAME
  value: myapp
  required: true
- description: nginx.conf template. It will be copied to config map and used instead of /etc/nginx/nginx.conf
  displayName: nginx.conf
  name: NGINX_CONFIG
  required: true
  value: |
    worker_processes  1;
    #worker_processes  auto;
    worker_rlimit_nofile 2048;
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    events {
        worker_connections  1024;
        multi_accept on;
        use epoll;
    }
    http {
        #fix temp paths
        client_body_temp_path /tmp/nginx/client_temp 1 2;
        proxy_temp_path /tmp/nginx/proxy_temp 1 2;
        fastcgi_temp_path /tmp/nginx/fastcgi_temp 1 2;
        uwsgi_temp_path /tmp/nginx/uwsgi_temp 1 2;
        scgi_temp_path /tmp/nginx/scgi_temp 1 2;
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
        #access_log  logs/access.log  main;
        access_log /dev/stdout;
        error_log /dev/stderr;
        sendfile        on;
        server_tokens off;
        tcp_nopush on;
        tcp_nodelay on;
        types_hash_max_size 2048;
        client_max_body_size 20M;
        open_file_cache max=1000;
        #keepalive_timeout  0;
        keepalive_timeout  65;
        #gzip  on;
        gzip on;
        gzip_vary on;
        gzip_disable "msie6";
        gzip_comp_level 6;
        gzip_min_length 1100;
        gzip_buffers 16 8k;
        gzip_proxied any;
        gzip_types
            text/plain
            text/css
            text/js
            text/xml
            text/javascript
            application/javascript
            application/x-javascript
            application/json
            application/xml
            application/xml+rss;
        large_client_header_buffers 4 32k;
        server_names_hash_bucket_size  64;
        charset UTF-8;
        #server configs are stored in ConfigMap as separate fields
        include /etc/nginx/openshift/*.conf;
    }
- description: default site template, later you can add more 'files' into config map as well
  displayName: default.conf
  name: NGINX_WWW_CONFIG
  required: true
  value: |
    server {
        listen 8080 default_server;
        listen [::]:8080 default_server ipv6only=on;
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
objects:
- apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: sa-nginx
- apiVersion: v1
  kind: ImageStream
  metadata:
    creationTimestamp: null
    labels:
      app: ${APPLICATION_NAME}
      application: ${APPLICATION_NAME}
    name: is-ng-dmf
  spec:
    dockerImageRepository: ""
    tags:
      -
       from:
         kind: DockerImage
         name: "{{angular_image}}"
       name: ng-dmf_pseudo_tag
       importPolicy:
         scheduled: true
  status:
    dockerImageRepository: ""
- apiVersion: v1
  kind: ConfigMap
  metadata:
    name: cm-ng-dmf-nginx-config
  data:
    nginx.conf.template: |
        ${NGINX_CONFIG}
    default.conf: |
        ${NGINX_WWW_CONFIG}
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      description: The nodejs web server's http port for the angular application demo.
    labels:
      application: ${APPLICATION_NAME}
    name: ${APPLICATION_NAME}-ng-dmf
  spec:
    ports:
    - port: 8080
      targetPort: 8080
    selector:
      deploymentConfig: ${APPLICATION_NAME}-ng-dmf
- apiVersion: v1
  id: ${APPLICATION_NAME}-ng-dmf-http
  kind: Route
  metadata:
    annotations:
      description: Route for nodejs mortgages http service.
    labels:
      application: ${APPLICATION_NAME}
    name: ${APPLICATION_NAME}-ng-dmf
  spec:
    to:
      name: ${APPLICATION_NAME}-ng-dmf
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    labels:
      application: ${APPLICATION_NAME}
    name: ${APPLICATION_NAME}-ng-dmf
  spec:
    paused: false
    replicas: 1
    selector:
      deploymentConfig: ${APPLICATION_NAME}-ng-dmf
    strategy:
      type: Rolling
    template:
      metadata:
        labels:
          application: ${APPLICATION_NAME}
          deploymentConfig: ${APPLICATION_NAME}-ng-dmf
        name: ${APPLICATION_NAME}-ng-dmf
      spec:
        containers:
        - image: "{{angular_image}}"
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 10
            initialDelaySeconds: 50
            periodSeconds: 10
            tcpSocket:
              port: 8080
            timeoutSeconds: 1
          readinessProbe:
            initialDelaySeconds: 50
            failureThreshold: 30
            periodSeconds: 10
            tcpSocket:
              port: 8080
            timeoutSeconds: 1
          name: ${APPLICATION_NAME}-ng-dmf
          ports:
          - containerPort: 8080
            name: http
            protocol: TCP
          resources:
            limits:
              cpu: "0.5"
              memory: 512Mi
            requests:
              cpu: "0.25"
              memory: 256Mi
          command:
            - /bin/sh
            - '-c'
            - >-
              mkdir /tmp/nginx &&
              nginx -c /etc/nginx/openshift/nginx.conf.template -g 'daemon off; pid /tmp/nginx.pid;'
          volumeMounts:
          - mountPath: /etc/nginx/openshift
            name: vol-ng-dmf-nginx-conf
          terminationMessagePath: /dev/termination-log
        serviceAccountName: sa-nginx
        volumes:
        - configMap:
            name: cm-ng-dmf-nginx-config
          name: vol-ng-dmf-nginx-conf
    triggers:
    - imageChangeParams:
        automatic: true
        containerNames:
        - ${APPLICATION_NAME}-ng-dmf
        from:
          kind: ImageStreamTag
          name: is-ng-dmf:ng-dmf_pseudo_tag
      type: ImageChange
    - type: ConfigChange