You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/11/03 01:09:59 UTC
[GitHub] csantanapr closed pull request #40: Add persistence to consul and couchdb
csantanapr closed pull request #40: Add persistence to consul and couchdb
URL: https://github.com/apache/incubator-openwhisk-deploy-kube/pull/40
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ansible-kube/environments/kube/files/consul.yml b/ansible-kube/environments/kube/files/consul.yml
index 7dfef00..2c20cbb 100644
--- a/ansible-kube/environments/kube/files/consul.yml
+++ b/ansible-kube/environments/kube/files/consul.yml
@@ -12,6 +12,7 @@ spec:
metadata:
labels:
name: consul
+
spec:
restartPolicy: Always
volumes:
@@ -21,10 +22,29 @@ spec:
- name: consulconf
configMap:
name: consul
+ - name: consuldata
+ persistentVolumeClaim:
+ claimName: openwhisk-consul
+
+ initContainers:
+ - name: reset-consul
+ imagePullPolicy: IfNotPresent
+ image: busybox
+ command: ['sh', '-c', '[ ! -d /consul/data/raft ] || echo "[\"$MY_IP:8300\"]" > /consul/data/raft/peers.json']
+ volumeMounts:
+ - name: consuldata
+ mountPath: "/consul/data"
+ env:
+ - name: MY_IP
+ valueFrom:
+ fieldRef:
+ fieldPath: status.podIP
+
containers:
- name: consul
imagePullPolicy: IfNotPresent
- image: consul:v0.7.0
+ image: consul:0.7.5
+ args: [ "agent", "-server", "-config-file", "/consul/config/config.json" ]
ports:
- name: server
protocol: TCP
@@ -65,9 +85,12 @@ spec:
volumeMounts:
- name: consulconf
mountPath: "/consul/config/config.json"
+ - name: consuldata
+ mountPath: "/consul/data"
- name: registrator
image: gliderlabs/registrator
+ imagePullPolicy: IfNotPresent
env:
- name: MY_POD_IP
valueFrom:
diff --git a/ansible-kube/environments/kube/files/db.yml b/ansible-kube/environments/kube/files/db.yml
index 78de1af..8ec2a72 100644
--- a/ansible-kube/environments/kube/files/db.yml
+++ b/ansible-kube/environments/kube/files/db.yml
@@ -15,6 +15,18 @@ spec:
spec:
restartPolicy: Always
+ volumes:
+ - name: couchdbconfig
+ projected:
+ sources:
+ - secret:
+ name: couchdb-admins
+ - configMap:
+ name: couchdb-config
+ - name: couchdbdata
+ persistentVolumeClaim:
+ claimName: openwhisk-couchdb
+
containers:
- name: couchdb
imagePullPolicy: IfNotPresent
@@ -22,3 +34,8 @@ spec:
ports:
- name: couchdb
containerPort: 5984
+ volumeMounts:
+ - name: couchdbconfig
+ mountPath: /usr/local/etc/couchdb/local.d/
+ - name: couchdbdata
+ mountPath: /usr/local/var/lib/couchdb
diff --git a/ansible-kube/environments/kube/group_vars/all b/ansible-kube/environments/kube/group_vars/all
index bc7b59e..d4c56ed 100644
--- a/ansible-kube/environments/kube/group_vars/all
+++ b/ansible-kube/environments/kube/group_vars/all
@@ -20,6 +20,7 @@ db_password: couch_password
db_auth: "subjects"
db_prefix: "openwhisk_kube_"
db_split_actions_and_activations: true
+db_config_dir: /tmp/couchdb
# apigw db credentials minimum read/write
db_apigw_username: "couch_user"
diff --git a/ansible-kube/roles/consul/tasks/deploy.yml b/ansible-kube/roles/consul/tasks/deploy.yml
index c7f61e4..582532e 100644
--- a/ansible-kube/roles/consul/tasks/deploy.yml
+++ b/ansible-kube/roles/consul/tasks/deploy.yml
@@ -19,7 +19,8 @@
- name: create configmap
shell: "kubectl create configmap consul --from-file={{ consul_conf_dir }}/config.json"
-
+ ignore_errors: yes
+
- name: create consul deployment
shell: "kubectl apply -f {{kube_pod_dir}}/consul.yml"
diff --git a/ansible-kube/roles/consul/templates/config.json.j2 b/ansible-kube/roles/consul/templates/config.json.j2
index e64cb5f..3cda6ce 100644
--- a/ansible-kube/roles/consul/templates/config.json.j2
+++ b/ansible-kube/roles/consul/templates/config.json.j2
@@ -5,7 +5,6 @@
"ui": true,
"log_level": "WARN",
"client_addr": "0.0.0.0",
- "advertise_addr": "{{ consul_host }}",
"ports": {
"dns": 8600
},
diff --git a/ansible-kube/roles/couchdb/tasks/deploy.yml b/ansible-kube/roles/couchdb/tasks/deploy.yml
index c26c084..2fb6f2a 100644
--- a/ansible-kube/roles/couchdb/tasks/deploy.yml
+++ b/ansible-kube/roles/couchdb/tasks/deploy.yml
@@ -5,6 +5,27 @@
fail: msg="The db provider in your {{ inventory_dir }}/group_vars/all is {{ db_provider }}, it has to be CouchDB, pls double check"
when: db_provider != "CouchDB"
+- name: ensure couchdb config directory exists
+ file:
+ path: "{{ db_config_dir }}"
+ state: directory
+
+- name: copy template from local to remote (which is really local) and fill in templates
+ template:
+ src: "{{ item }}.j2"
+ dest: "{{ db_config_dir }}/{{ item }}"
+ with_items:
+ - admins.ini
+ - query_server.ini
+
+- name: create configmap
+ shell: "kubectl create configmap couchdb-config --from-file={{ db_config_dir }}/query_server.ini"
+ ignore_errors: yes
+
+- name: create secrets
+ shell: "kubectl create secret generic couchdb-admins --from-file={{ db_config_dir }}//admins.ini"
+ ignore_errors: yes
+
- name: create db pod
shell: "kubectl apply -f {{kube_pod_dir}}/db.yml"
@@ -14,24 +35,3 @@
host: "{{ db_host }}"
port: "{{ db_port }}"
timeout: 60
-
-- name: create admin user
- uri:
- url: "{{ db_protocol }}://{{ db_host }}:{{ db_port }}/_config/admins/{{ db_username }}"
- method: PUT
- body: >
- "{{ db_password }}"
- body_format: json
- status_code: 200
-
-- name: disable reduce limit on views
- uri:
- url: "{{ db_protocol }}://{{ db_host }}:{{ db_port }}/_config/query_server_config/reduce_limit"
- method: PUT
- body: >
- "false"
- body_format: json
- status_code: 200
- user: "{{ db_username }}"
- password: "{{ db_password }}"
- force_basic_auth: yes
diff --git a/ansible-kube/roles/couchdb/templates/admins.ini.j2 b/ansible-kube/roles/couchdb/templates/admins.ini.j2
new file mode 100644
index 0000000..57c3042
--- /dev/null
+++ b/ansible-kube/roles/couchdb/templates/admins.ini.j2
@@ -0,0 +1,2 @@
+[admins]
+{{ db_username }} = {{ db_password }}
\ No newline at end of file
diff --git a/ansible-kube/roles/couchdb/templates/query_server.ini.j2 b/ansible-kube/roles/couchdb/templates/query_server.ini.j2
new file mode 100644
index 0000000..53bda4b
--- /dev/null
+++ b/ansible-kube/roles/couchdb/templates/query_server.ini.j2
@@ -0,0 +1,2 @@
+[query_server_config]
+reduce_limit = false
\ No newline at end of file
diff --git a/configure/cleanup.sh b/configure/cleanup.sh
index 0c71f36..d447e05 100755
--- a/configure/cleanup.sh
+++ b/configure/cleanup.sh
@@ -17,12 +17,15 @@ kubectl -n openwhisk delete statefulsets invoker
kubectl -n openwhisk delete deployment nginx
# delete configmaps
+kubectl -n openwhisk delete cm couchdb-config
kubectl -n openwhisk delete cm consul
kubectl -n openwhisk delete cm controller
kubectl -n openwhisk delete cm nginx
# delete secrets
kubectl -n openwhisk delete secret nginx
+kubectl -n openwhisk delete secret couchdb-admins
+
# delete services
kubectl -n openwhisk delete service couchdb
diff --git a/configure/configure_whisk.yml b/configure/configure_whisk.yml
index 4306f95..2c608b8 100644
--- a/configure/configure_whisk.yml
+++ b/configure/configure_whisk.yml
@@ -16,6 +16,6 @@ spec:
restartPolicy: Never
containers:
- name: configure-openwhisk
- image: danlavine/whisk_config:v1.5.6
+ image: mastermikeyboy/whisk_config:v1.6.2-dev
imagePullPolicy: Always
command: [ "/incubator-openwhisk-deploy-kube/configure/configure.sh" ]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services