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
1diff --git a/src/charm.py b/src/charm.py
2index 69c317d..147eda4 100755
3--- a/src/charm.py
4+++ b/src/charm.py
5@@ -144,11 +144,12 @@ class WordpressK8sCharm(CharmBase):
6 # Only the leader can set_spec().
7 if self.model.unit.is_leader():
8 spec = self.make_pod_spec()
9+ resources = self.make_pod_resources()
10
11 msg = "Configuring pod"
12 logger.info(msg)
13 self.model.unit.status = MaintenanceStatus(msg)
14- self.model.pod.set_spec(spec)
15+ self.model.pod.set_spec(spec, resources)
16
17 msg = "Pod configured"
18 logger.info(msg)
19@@ -167,15 +168,15 @@ class WordpressK8sCharm(CharmBase):
20 ]
21
22 spec = {
23- "containers": [
24- {
25- "name": self.app.name,
26- "imageDetails": {"imagePath": config["image"]},
27- "ports": ports,
28- "config": secure_pod_config,
29- "readinessProbe": {"exec": {"command": ["/bin/cat", "/srv/wordpress-helpers/.ready"]}},
30- }
31- ]
32+ "version": 2,
33+ "containers": [{
34+ "name": self.app.name,
35+ "imageDetails": {
36+ "imagePath": config["image"]
37+ },
38+ "ports": ports,
39+ "config": secure_pod_config,
40+ }]
41 }
42
43 out = io.StringIO()
44@@ -190,6 +191,34 @@ class WordpressK8sCharm(CharmBase):
45
46 return spec
47
48+ def make_pod_resources(self):
49+ resources = {
50+ "kubernetesResources": {
51+ "ingressResources": [{
52+ "name": "{}-ingress".format(self.app.name),
53+ "spec": {
54+ "rules": [{
55+ "http": {
56+ "paths": [{
57+ "path": "/",
58+ "backend": {
59+ "serviceName": self.app.name,
60+ "servicePort": 80
61+ }
62+ }]
63+ }
64+ }]
65+ }
66+ }]
67+ }
68+ }
69+
70+ out = io.StringIO()
71+ pprint(resources, out)
72+ logger.info("This is the Kubernetes Pod resources <<EOM\n{}\nEOM".format(out.getvalue()))
73+
74+ return resources
75+
76 def is_valid_config(self):
77 is_valid = True
78 config = self.model.config

Subscribers

People subscribed via source and target branches