Merge ~barryprice/charm-k8s-wordpress/+git/charm-k8s-wordpress:master into charm-k8s-wordpress:master

Proposed by Barry Price
Status: Superseded
Proposed branch: ~barryprice/charm-k8s-wordpress/+git/charm-k8s-wordpress:master
Merge into: charm-k8s-wordpress:master
Diff against target: 96 lines (+46/-11)
1 file modified
src/charm.py (+46/-11)
Reviewer Review Type Date Requested Status
Wordpress Charmers Pending
Review via email: mp+384326@code.launchpad.net

Commit message

Add an Ingress resource to our pod spec, hard-coded port for now

To post a comment you must log in.
e0627a7... by Barry Price

Add an Ingress resource to our pod spec, hard-coded port for now

Unmerged commits

e0627a7... by Barry Price

Add an Ingress resource to our pod spec, hard-coded port for now

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/charm.py b/src/charm.py
2index 69c317d..9f2cb24 100755
3--- a/src/charm.py
4+++ b/src/charm.py
5@@ -43,7 +43,7 @@ def generate_pod_config(config, secured=True):
6 if config.get("wp_plugin_akismet_key"):
7 pod_config["WP_PLUGIN_AKISMET_KEY"] = config["wp_plugin_akismet_key"]
8 if config.get("wp_plugin_openstack-objectstorage_config"):
9- # Actual plugin name is 'openstack-objectstorage', but we're only
10+ # actual plugin name is 'openstack-objectstorage', but we're only
11 # implementing the 'swift' portion of it.
12 wp_plugin_swift_config = safe_load(config.get("wp_plugin_openstack-objectstorage_config"))
13 pod_config["SWIFT_AUTH_URL"] = wp_plugin_swift_config.get('auth-url')
14@@ -141,14 +141,15 @@ class WordpressK8sCharm(CharmBase):
15 self.model.unit.status = ActiveStatus()
16
17 def configure_pod(self):
18- # Only the leader can set_spec().
19+ # Only the leader can set_spec()
20 if self.model.unit.is_leader():
21 spec = self.make_pod_spec()
22+ resources = self.make_pod_resources()
23
24 msg = "Configuring pod"
25 logger.info(msg)
26 self.model.unit.status = MaintenanceStatus(msg)
27- self.model.pod.set_spec(spec)
28+ self.model.pod.set_spec(spec, resources)
29
30 msg = "Pod configured"
31 logger.info(msg)
32@@ -167,15 +168,25 @@ class WordpressK8sCharm(CharmBase):
33 ]
34
35 spec = {
36- "containers": [
37- {
38- "name": self.app.name,
39- "imageDetails": {"imagePath": config["image"]},
40- "ports": ports,
41- "config": secure_pod_config,
42- "readinessProbe": {"exec": {"command": ["/bin/cat", "/srv/wordpress-helpers/.ready"]}},
43+ "containers": [{
44+ "name": self.app.name,
45+ "imageDetails": {
46+ "imagePath": config["image"]
47+ },
48+ "ports": ports,
49+ "config": secure_pod_config,
50+ "startupProbe": {
51+ "exec": {
52+ "command": ["/bin/cat", "/srv/wordpress-helpers/.ready"]
53+ }
54+ },
55+ "livenessProbe": {
56+ "httpGet": {
57+ "path": "/",
58+ "port": 80,
59+ }
60 }
61- ]
62+ }]
63 }
64
65 out = io.StringIO()
66@@ -190,6 +201,30 @@ class WordpressK8sCharm(CharmBase):
67
68 return spec
69
70+ def make_pod_resources(self):
71+ resources = {
72+ "kubernetesResources": {
73+ "ingressResources": [{
74+ "name": "{}-ingress".format(self.app.name),
75+ "spec": {
76+ "rules": [{
77+ "http": {
78+ "paths": [{
79+ "path": "/",
80+ "backend": {
81+ "serviceName": self.app.name,
82+ "servicePort": 80
83+ }
84+ }]
85+ }
86+ }]
87+ }
88+ }]
89+ }
90+ }
91+
92+ return resources
93+
94 def is_valid_config(self):
95 is_valid = True
96 config = self.model.config

Subscribers

People subscribed via source and target branches