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

Proposed by Barry Price
Status: Work in progress
Proposed branch: ~barryprice/charm-k8s-wordpress/+git/charm-k8s-wordpress:master
Merge into: charm-k8s-wordpress:master
Diff against target: 78 lines (+39/-10)
1 file modified
src/charm.py (+39/-10)
Reviewer Review Type Date Requested Status
Wordpress Charmers Pending
Review via email: mp+384331@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.
3ab42f7... by Barry Price

Typos

Revision history for this message
Barry Price (barryprice) wrote :

n.b. the current target cluster doesn't recognise "startupProbe" so please do not merge until I've got (at least) that issue figured out :)

cd483ec... by Barry Price

Drop probes temporarily as we're seeing parsing issues, add 'version: 2' to activate ingress resource

Revision history for this message
Barry Price (barryprice) wrote :

This now deploys cleanly, but defines no probes.

It can be merged as-is, as long as re-adding probes is taken care of at some point.

Unmerged commits

cd483ec... by Barry Price

Drop probes temporarily as we're seeing parsing issues, add 'version: 2' to activate ingress resource

3ab42f7... by Barry Price

Typos

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..147eda4 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -144,11 +144,12 @@ class WordpressK8sCharm(CharmBase):
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,15 @@ class WordpressK8sCharm(CharmBase):
167 ]168 ]
168169
169 spec = {170 spec = {
170 "containers": [171 "version": 2,
171 {172 "containers": [{
172 "name": self.app.name,173 "name": self.app.name,
173 "imageDetails": {"imagePath": config["image"]},174 "imageDetails": {
174 "ports": ports,175 "imagePath": config["image"]
175 "config": secure_pod_config,176 },
176 "readinessProbe": {"exec": {"command": ["/bin/cat", "/srv/wordpress-helpers/.ready"]}},177 "ports": ports,
177 }178 "config": secure_pod_config,
178 ]179 }]
179 }180 }
180181
181 out = io.StringIO()182 out = io.StringIO()
@@ -190,6 +191,34 @@ class WordpressK8sCharm(CharmBase):
190191
191 return spec192 return spec
192193
194 def make_pod_resources(self):
195 resources = {
196 "kubernetesResources": {
197 "ingressResources": [{
198 "name": "{}-ingress".format(self.app.name),
199 "spec": {
200 "rules": [{
201 "http": {
202 "paths": [{
203 "path": "/",
204 "backend": {
205 "serviceName": self.app.name,
206 "servicePort": 80
207 }
208 }]
209 }
210 }]
211 }
212 }]
213 }
214 }
215
216 out = io.StringIO()
217 pprint(resources, out)
218 logger.info("This is the Kubernetes Pod resources <<EOM\n{}\nEOM".format(out.getvalue()))
219
220 return resources
221
193 def is_valid_config(self):222 def is_valid_config(self):
194 is_valid = True223 is_valid = True
195 config = self.model.config224 config = self.model.config

Subscribers

People subscribed via source and target branches