I pulled the charm solr charm and installed it.
I dumped the Juju db to see the pod spec that was sent in:
containers:
- envConfig:
SOLR_JAVA_MEM: -Xms2g -Xmx3g
SOLR_LOG_LEVEL: INFO
imageDetails:
imagePath: bitnami/solr:8.7.0-debian-10-r31
imagePullPolicy: Always
name: ddd
ports:
- containerPort: 8983
name: solr
protocol: TCP
kubernetesResources:
pod:
securityContext:
fsGroup: 1001
runAsGroup: 1001
runAsUser: 1001
version: 3
kubernetesResources:
secrets:
- data: {}
name: charm-secrets
type: Opaque
services:
- name: solr-port
spec:
clusterIP: ''
ports:
- name: solr
port: 8983
protocol: TCP
type: NodePort
There’s 2 kubernetesResources
sections. It does still parse ok but comes out as:
{
"kubernetesResources": {
"secrets": [
{
"data": {},
"type": "Opaque",
"name": "charm-secrets"
}
],
"services": [
{
"name": "solr-port",
"spec": {
"clusterIP": "",
"type": "NodePort",
"ports": [
{
"protocol": "TCP",
"name": "solr",
"port": 8983
}
]
}
}
]
},
"version": 3,
"containers": [
{
"imagePullPolicy": "Always",
"imageDetails": {
"imagePath": "bitnami/solr:8.7.0-debian-10-r31"
},
"ports": [
{
"protocol": "TCP",
"containerPort": 8983,
"name": "solr"
}
],
"envConfig": {
"SOLR_JAVA_MEM": "-Xms2g -Xmx3g",
"SOLR_LOG_LEVEL": "INFO"
},
"name": "ddd"
}
]
}
I fixed the charm and got the desired result. Here’s the diff:
diff --git a/src/charm.py b/src/charm.py
index 82b7aad..da5e687 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -72,15 +72,6 @@ class SolrCharm(CharmBase):
]
spec = {
"version": 3,
- "kubernetesResources":{
- "pod":{
- "securityContext":{
- "fsGroup": 1001,
- "runAsUser": 1001,
- "runAsGroup":1001,
- }
- }
- },
"containers": [
{
"name": self.app.name,
@@ -108,7 +99,7 @@ class SolrCharm(CharmBase):
# {
# "name":"binami",
# "mountPath":"/bitnami",
- #
+ #
# }
# ]
#}
@@ -135,6 +126,13 @@ class SolrCharm(CharmBase):
resources = {
"secrets": [{"name": "charm-secrets", "type": "Opaque", "data": secrets_data}],
"services": services,
+ "pod": {
+ "securityContext": {
+ "fsGroup": 1001,
+ "runAsUser": 1001,
+ "runAsGroup": 1001,
+ }
+ }
}
logger.info(f"Pod resources <<EOM\n{yaml.dump(resources)}\nEOM")
The issues is that the pod security context info was being added to the wrong section.