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
diff --git a/src/charm.py b/src/charm.py
index 69c317d..9f2cb24 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -43,7 +43,7 @@ def generate_pod_config(config, secured=True):
43 if config.get("wp_plugin_akismet_key"):43 if config.get("wp_plugin_akismet_key"):
44 pod_config["WP_PLUGIN_AKISMET_KEY"] = config["wp_plugin_akismet_key"]44 pod_config["WP_PLUGIN_AKISMET_KEY"] = config["wp_plugin_akismet_key"]
45 if config.get("wp_plugin_openstack-objectstorage_config"):45 if config.get("wp_plugin_openstack-objectstorage_config"):
46 # Actual plugin name is 'openstack-objectstorage', but we're only46 # actual plugin name is 'openstack-objectstorage', but we're only
47 # implementing the 'swift' portion of it.47 # implementing the 'swift' portion of it.
48 wp_plugin_swift_config = safe_load(config.get("wp_plugin_openstack-objectstorage_config"))48 wp_plugin_swift_config = safe_load(config.get("wp_plugin_openstack-objectstorage_config"))
49 pod_config["SWIFT_AUTH_URL"] = wp_plugin_swift_config.get('auth-url')49 pod_config["SWIFT_AUTH_URL"] = wp_plugin_swift_config.get('auth-url')
@@ -141,14 +141,15 @@ class WordpressK8sCharm(CharmBase):
141 self.model.unit.status = ActiveStatus()141 self.model.unit.status = ActiveStatus()
142142
143 def configure_pod(self):143 def configure_pod(self):
144 # Only the leader can set_spec().144 # Only the leader can set_spec()
145 if self.model.unit.is_leader():145 if self.model.unit.is_leader():
146 spec = self.make_pod_spec()146 spec = self.make_pod_spec()
147 resources = self.make_pod_resources()
147148
148 msg = "Configuring pod"149 msg = "Configuring pod"
149 logger.info(msg)150 logger.info(msg)
150 self.model.unit.status = MaintenanceStatus(msg)151 self.model.unit.status = MaintenanceStatus(msg)
151 self.model.pod.set_spec(spec)152 self.model.pod.set_spec(spec, resources)
152153
153 msg = "Pod configured"154 msg = "Pod configured"
154 logger.info(msg)155 logger.info(msg)
@@ -167,15 +168,25 @@ class WordpressK8sCharm(CharmBase):
167 ]168 ]
168169
169 spec = {170 spec = {
170 "containers": [171 "containers": [{
171 {172 "name": self.app.name,
172 "name": self.app.name,173 "imageDetails": {
173 "imageDetails": {"imagePath": config["image"]},174 "imagePath": config["image"]
174 "ports": ports,175 },
175 "config": secure_pod_config,176 "ports": ports,
176 "readinessProbe": {"exec": {"command": ["/bin/cat", "/srv/wordpress-helpers/.ready"]}},177 "config": secure_pod_config,
178 "startupProbe": {
179 "exec": {
180 "command": ["/bin/cat", "/srv/wordpress-helpers/.ready"]
181 }
182 },
183 "livenessProbe": {
184 "httpGet": {
185 "path": "/",
186 "port": 80,
187 }
177 }188 }
178 ]189 }]
179 }190 }
180191
181 out = io.StringIO()192 out = io.StringIO()
@@ -190,6 +201,30 @@ class WordpressK8sCharm(CharmBase):
190201
191 return spec202 return spec
192203
204 def make_pod_resources(self):
205 resources = {
206 "kubernetesResources": {
207 "ingressResources": [{
208 "name": "{}-ingress".format(self.app.name),
209 "spec": {
210 "rules": [{
211 "http": {
212 "paths": [{
213 "path": "/",
214 "backend": {
215 "serviceName": self.app.name,
216 "servicePort": 80
217 }
218 }]
219 }
220 }]
221 }
222 }]
223 }
224 }
225
226 return resources
227
193 def is_valid_config(self):228 def is_valid_config(self):
194 is_valid = True229 is_valid = True
195 config = self.model.config230 config = self.model.config

Subscribers

People subscribed via source and target branches