Skip to content

Commit

Permalink
Extended logging (#138)
Browse files Browse the repository at this point in the history
* extended logging config added to routers

* fixed error

* clauses missed
  • Loading branch information
k8soneill authored and benbacon committed May 31, 2019
1 parent b2e6e9a commit 03ae496
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 45 deletions.
47 changes: 2 additions & 45 deletions roles/openshiftpostdeployment/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,51 +65,6 @@
command: /usr/local/bin/oc set volume dc/registry-console --add --type=secret --secret-name=console-secret -m /etc/cockpit/ws-certs.d -n default
when: getCertificates == True

- name: Setup secondary network routers
command: /usr/local/bin/oc adm router router-secondary --replicas=0 --selector='router=secondary' --service-account=router -n default
when: multinetwork

- name: Setup secondary network router envs
command: /usr/local/bin/oc set env dc/router-secondary ROUTE_LABELS="router-secondary=true" -n default
when: multinetwork

- name: Allow Source IP to be received on primary router from the HAProxy
command: /usr/local/bin/oc set env dc/router ROUTER_USE_PROXY_PROTOCOL=true -n default

- name: Allow Source IP to be received on secondary router from HAProxy
command: /usr/local/bin/oc set env dc/router-secondary ROUTER_USE_PROXY_PROTOCOL=true -n default
when: multinetwork

- name: Scale up secondary network routers
vars:
net2_scale: "{{ groups['nodes_net2'] | length }}"
command: /usr/local/bin/oc scale dc router-secondary --replicas={{ net2_scale }} -n default
when: multinetwork

- name: Setup routers for private networks (extra gateway)
command: /usr/local/bin/oc adm router router-private --replicas=0 --selector='router-private=true' --service-account=router --stats-port=1937 --ports='7080:7080,7443:7443' -n default
when: extra_gateway_vip is defined

- name: Setup private network router environment
command: /usr/local/bin/oc set env dc/router-private {{ item }} -n default
with_items:
- ROUTER_SERVICE_HTTP_PORT=7080
- ROUTER_SERVICE_HTTPS_PORT=7443
- ROUTE_LABELS="router-private=true"
- ROUTER_SERVICE_NO_SNI_PORT=11443
- ROUTER_SERVICE_SNI_PORT=11444
when: extra_gateway_vip is defined

- name: Scale up private network routers
vars:
infra_scale: "{{ groups['nodes_infra'] | length }}"
command: /usr/local/bin/oc scale dc router-private --replicas={{ infra_scale }} -n default
when: extra_gateway_vip is defined

- name: Allow Source IP to be received on private router from HAProxy
command: /usr/local/bin/oc set env dc/router-private ROUTER_USE_PROXY_PROTOCOL=true -n default
when: extra_gateway_vip is defined

- name: Create 'monitoring' serviceaccount for monitoring use
command: /usr/local/bin/oc create serviceaccount monitoring -n openshift-infra

Expand Down Expand Up @@ -145,5 +100,7 @@
hostname: "prometheus"
when: getCertificates == True

- include_tasks: routers.yml

- include_tasks: squid-whitelist.yml
when: multinetwork
74 changes: 74 additions & 0 deletions roles/openshiftpostdeployment/tasks/routers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Default routers
- name: Setup default router environment
command: /usr/local/bin/oc set env dc/router {{ item }} -n default
with_items:
- ROUTER_USE_PROXY_PROTOCOL=true
- ROUTER_LOG_LEVEL=debug

- name: Setup rsyslog configMap for default router extended logging
template:
src: templates/extended-logging-configmap.j2
dest: ~/extended-logging-configmap.yml
force: yes
backup: no

- name: Create rsyslog configMap for default router extended logging
command: /usr/local/bin/oc create -f ~/extended-logging-configmap.yml

- name: Remove configMap template
file:
path: ~/extended-logging-configmap.yml
state: absent

- name: Patch router deployment
command: /usr/local/bin/oc patch dc/router -p '{"spec":{"template":{"spec":{"containers":[{"name":"router","env":[{"name":"ROUTER_SYSLOG_ADDRESS","value":"/var/lib/rsyslog/rsyslog.sock"}],"volumeMounts":[{"mountPath":"/var/lib/rsyslog","name":"rsyslog-socket"}]},{"name":"syslog","command":["/sbin/rsyslogd","-n","-i","/tmp/rsyslog.pid","-f","/etc/rsyslog/rsyslog.conf"],"image":"registry.redhat.io/openshift3/ose-haproxy-router:v3.11","imagePullPolicy":"IfNotPresent","resources":{"requests":{"cpu":"100m","memory":"256Mi"}},"volumeMounts":[{"mountPath":"/etc/rsyslog","name":"rsyslog-config"},{"mountPath":"/var/lib/rsyslog","name":"rsyslog-socket"}]}],"volumes":[{"configMap":{"name":"rsyslog-config"},"name":"rsyslog-config"},{"emptyDir":{},"name":"rsyslog-socket"}]}}}}' -n default

# Net2 routers
- name: Setup secondary network routers
command: /usr/local/bin/oc adm router router-secondary --replicas=0 --selector='router=secondary' --service-account=router -n default
when: multinetwork

- name: Setup secondary network router envs
command: /usr/local/bin/oc set env dc/router-secondary {{ item }} -n default
with_items:
- ROUTE_LABELS="router-secondary=true"
- ROUTER_LOG_LEVEL=debug
- ROUTER_USE_PROXY_PROTOCOL=true
when: multinetwork

- name: Patch secondary router deployment to use extended logging
command: /usr/local/bin/oc patch dc/router-secondary -p '{"spec":{"template":{"spec":{"containers":[{"name":"router","env":[{"name":"ROUTER_SYSLOG_ADDRESS","value":"/var/lib/rsyslog/rsyslog.sock"}],"volumeMounts":[{"mountPath":"/var/lib/rsyslog","name":"rsyslog-socket"}]},{"name":"syslog","command":["/sbin/rsyslogd","-n","-i","/tmp/rsyslog.pid","-f","/etc/rsyslog/rsyslog.conf"],"image":"registry.redhat.io/openshift3/ose-haproxy-router:v3.11","imagePullPolicy":"IfNotPresent","resources":{"requests":{"cpu":"100m","memory":"256Mi"}},"volumeMounts":[{"mountPath":"/etc/rsyslog","name":"rsyslog-config"},{"mountPath":"/var/lib/rsyslog","name":"rsyslog-socket"}]}],"volumes":[{"configMap":{"name":"rsyslog-config"},"name":"rsyslog-config"},{"emptyDir":{},"name":"rsyslog-socket"}]}}}}' -n default
when: multinetwork

- name: Scale up secondary network routers
vars:
net2_scale: "{{ groups['nodes_net2'] | length }}"
command: /usr/local/bin/oc scale dc router-secondary --replicas={{ net2_scale }} -n default
when: multinetwork

# Extra gateway routers
- name: Setup routers for private networks (extra gateway)
command: /usr/local/bin/oc adm router router-private --replicas=0 --selector='router-private=true' --service-account=router --stats-port=1937 --ports='7080:7080,7443:7443' -n default
when: extra_gateway_vip is defined

- name: Setup private network router environment
command: /usr/local/bin/oc set env dc/router-private {{ item }} -n default
with_items:
- ROUTER_SERVICE_HTTP_PORT=7080
- ROUTER_SERVICE_HTTPS_PORT=7443
- ROUTE_LABELS="router-private=true"
- ROUTER_SERVICE_NO_SNI_PORT=11443
- ROUTER_SERVICE_SNI_PORT=11444
- ROUTER_USE_PROXY_PROTOCOL=true
- ROUTER_LOG_LEVEL=debug
when: extra_gateway_vip is defined

- name: Patch private router deployment to use extended logging
command: /usr/local/bin/oc patch dc/router-private -p '{"spec":{"template":{"spec":{"containers":[{"name":"router","env":[{"name":"ROUTER_SYSLOG_ADDRESS","value":"/var/lib/rsyslog/rsyslog.sock"}],"volumeMounts":[{"mountPath":"/var/lib/rsyslog","name":"rsyslog-socket"}]},{"name":"syslog","command":["/sbin/rsyslogd","-n","-i","/tmp/rsyslog.pid","-f","/etc/rsyslog/rsyslog.conf"],"image":"registry.redhat.io/openshift3/ose-haproxy-router:v3.11","imagePullPolicy":"IfNotPresent","resources":{"requests":{"cpu":"100m","memory":"256Mi"}},"volumeMounts":[{"mountPath":"/etc/rsyslog","name":"rsyslog-config"},{"mountPath":"/var/lib/rsyslog","name":"rsyslog-socket"}]}],"volumes":[{"configMap":{"name":"rsyslog-config"},"name":"rsyslog-config"},{"emptyDir":{},"name":"rsyslog-socket"}]}}}}' -n default
when: extra_gateway_vip is defined

- name: Scale up private network routers
vars:
infra_scale: "{{ groups['nodes_infra'] | length }}"
command: /usr/local/bin/oc scale dc router-private --replicas={{ infra_scale }} -n default
when: extra_gateway_vip is defined
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
data:
rsyslog.conf: |
$ModLoad imuxsock
$SystemLogSocketName /var/lib/rsyslog/rsyslog.sock
$ModLoad omstdout.so
*.* :omstdout:
kind: ConfigMap
metadata:
name: rsyslog-config
namespace: default

0 comments on commit 03ae496

Please sign in to comment.