evhan
(Evan Hanson)
18 February 2020 01:15
1
Hi there,
I’m looking for a way to wire up a hostPath volume in a K8s charm, so that an existing directory on the K8s node is exposed to the charm. However, I haven’t found a way to do this.
AFAICT the Juju-native storage mechanism will either mount a new volume (via the kubernetes
type storage) or use an emptyDir
. Is that still correct? The K8s-native config I would like to approximate is:
# in a .spec for kind: Pod ...
containers:
- name: foo
#
# ... stuff ...
#
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
#
# ... more stuff ...
#
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
This is in progress as I type this
k8s charms currently support creating text files at specified mount points on the host volume.
files:
- name: configurations
mountPath: /etc/mysql/conf.d
files:
custom_mysql.cnf: |
[mysqld]
skip-host-cache
skip-name-resolve
query_cache_limit = 1M
We’ll extend this to support
hostpath volumes
configmap volumes
secret backed volumes
empty dir volumes
eg
files:
# text files (what we have now)
- name: configurations
mountPath: /etc/mysql/conf.d
files:
custom_mysql.cnf: |
[mysqld]
skip-host-cache
skip-name-resolve
query_cache_limit = 1M
# hostpath (files block is empty, else error)
- name: myhostpathstuff
mountPath: /host/etc/cni/net.d
hostPath:
path: /etc/cni/net.d
# configmap
- name: myconfigmapstuff
mountPath: /etc/otherstuff
configMap:
name: foo # this configmap here must be included in the `configmap` field.
files:
config.yaml: configkey
foo.yaml: foo.key
# emptyDir (files block is empty, else error)
- name: myemptydirstuff
mountPath: /etc/otherstuff
emptyDir:
medium: memory
For configMap and secret, files is optional. If unspecified, use all of the configMap keys.
1 Like
evhan
(Evan Hanson)
24 February 2020 02:15
3
That is fantastic news, thanks @wallyworld . We’ll be happy to give this a go when it’s available.