k8s spec must expose ports or fails with no error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Invalid
|
High
|
Yang Kelvin Liu |
Bug Description
Developing charms with the operator framework, and juju v2.7.1
Issue:
If you don't expose ports on the container in a k8s spec then there is no error and the pod doesn't get created.
Expected:
Error if the pod won't get created.
Ideal:
Allow for containers to be created with no exposed ports
Test steps:
Without ports:
- Charm sets spec like below.
self.framework.
'containers': [{
'name': 'no-ports-test',
},
'command': ['sh', '-c'],
'args': ['while(sleep 2); do date; done'],
}]
})
- I see logs like
$ kubectl -n test-k8s logs --tail=100 -f no-ports-
2020-01-29 02:01:38 INFO juju-log handle_event: StartEvent
2020-01-29 02:01:39 DEBUG start Pod.set_spec {"containers": [{"name": "no-ports-test", "imageDetails": {"imagePath": "busybox"}, "command": ["sh", "-c"], "args": ["while(sleep 2); do date; done"], "imagePullPolicy": "IfNotPresent"}]}
2020-01-29 02:01:40 INFO juju-log handle_event: LeaderElectedEvent
2020-01-29 02:01:40 DEBUG leader-elected Pod.set_spec {"containers": [{"name": "no-ports-test", "imageDetails": {"imagePath": "busybox"}, "command": ["sh", "-c"], "args": ["while(sleep 2); do date; done"], "imagePullPolicy": "IfNotPresent"}]}
2020-01-29 02:01:41 INFO juju-log handle_event: ConfigChangedEvent
2020-01-29 02:01:42 DEBUG config-changed Pod.set_spec {"containers": [{"name": "no-ports-test", "imageDetails": {"imagePath": "busybox"}, "command": ["sh", "-c"], "args": ["while(sleep 2); do date; done"], "imagePullPolicy": "IfNotPresent"}]}
No more logs and the pod doesn't get created.
With ports:
- Charm sets spec like below.
self.framework.
'containers': [{
'name': 'no-ports-test',
},
'command': ['sh', '-c'],
'args': ['while(sleep 2); do date; done'],
'ports': [{
}],
}]
})
- I see logs like
$ kubectl -n test-k8s logs --tail=100 -f no-ports-
2020-01-29 02:08:10 INFO juju-log handle_event: StartEvent
2020-01-29 02:08:10 DEBUG start Pod.set_spec {"containers": [{"name": "no-ports-test", "imageDetails": {"imagePath": "busybox"}, "command": ["sh", "-c"], "args": ["while(sleep 2); do date; done"], "imagePullPolicy": "IfNotPresent", "ports": [{"containerPort": 80, "protocol": "TCP"}]}]}
2020-01-29 02:08:11 INFO juju-log handle_event: LeaderElectedEvent
2020-01-29 02:08:11 DEBUG leader-elected Pod.set_spec {"containers": [{"name": "no-ports-test", "imageDetails": {"imagePath": "busybox"}, "command": ["sh", "-c"], "args": ["while(sleep 2); do date; done"], "imagePullPolicy": "IfNotPresent", "ports": [{"containerPort": 80, "protocol": "TCP"}]}]}
2020-01-29 02:08:12 INFO juju-log handle_event: ConfigChangedEvent
2020-01-29 02:08:12 DEBUG config-changed Pod.set_spec {"containers": [{"name": "no-ports-test", "imageDetails": {"imagePath": "busybox"}, "command": ["sh", "-c"], "args": ["while(sleep 2); do date; done"], "imagePullPolicy": "IfNotPresent", "ports": [{"containerPort": 80, "protocol": "TCP"}]}]}
No more logs and the pod *DOES* get created.
tags: | added: k8s |
Changed in juju: | |
milestone: | none → 2.8-beta1 |
importance: | Undecided → High |
status: | New → Triaged |
Changed in juju: | |
status: | Triaged → In Progress |
assignee: | nobody → Yang Kelvin Liu (kelvin.liu) |
In this case, `juju status` shows the errors.