I’m looking for a working example of charm that implements InitContainer. Currently I’ve create this pod spec:
spec = {
'version': 3,
'initContainers': [{
'name': self.app.name + "-code-init",
'imageDetails': {
'imagePath': "busybox"
},
'args': ["sleep", "5"],
'kubernetes': {},
'ports': [{
'containerPort': 3001,
'name': 'init-http',
'protocol': 'TCP'
}]
}],
'containers': [{
'name': self.app.name,
'imageDetails': {
'imagePath': "busybox"
},
'args': ["sleep", "3600"],
'kubernetes': {},
'ports': [{
'containerPort': 3000,
'name': 'app-http',
'protocol': 'TCP'
}]
}]
}
self.model.pod.set_spec(spec)
But after deployment operator fails with this error
subprocess.CalledProcessError: Command '('/var/lib/juju/tools/unit-python-application-operator-9/pod-spec-set', '--file', '/tmp/tmphxfdekcq-pod-spec-set/spec.yaml')' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./src/charm.py", line 68, in <module>
main(PythonApplicationOperatorCharm)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/main.py", line 402, in main
_emit_charm_event(charm, dispatcher.event_name)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/main.py", line 140, in _emit_charm_event
event_to_emit.emit(*args, **kwargs)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/framework.py", line 278, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/framework.py", line 722, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/framework.py", line 767, in _reemit
custom_handler(event)
File "./src/charm.py", line 61, in _on_config_changed
self.model.pod.set_spec(spec)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/model.py", line 926, in set_spec
self._backend.pod_spec_set(spec, k8s_resources)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/model.py", line 1154, in pod_spec_set
self._run('pod-spec-set', *args)
File "/var/lib/juju/agents/unit-python-application-operator-9/charm/venv/ops/model.py", line 1051, in _run
raise ModelError(e.stderr)
ops.model.ModelError: b'ERROR json: unknown field "initContainers"\n'
2020-12-04 13:24:59 ERROR juju.worker.uniter.operation runhook.go:136 hook "config-changed" (via hook dispatching script: dispatch) failed: exit status 1
Can you help me get to the root cause?
I’m using k8s 1.19.3 (microk8s) with juju 2.8.6-groovy-amd64 and charmcraft 0.6.1+16.g86d77d9