The doctl
snap uses two personal-files
plugs as follows:
plugs:
kube-config:
interface: personal-files
write:
- $HOME/.kube
- $HOME/.kube/config
doctl-config:
interface: personal-files
write:
- $HOME/.config
- $HOME/.config/doctl
- $HOME/.config/doctl/.config
doctl
needs write access to the kube-config plug so devs can use kubectl
to interact with k8s clusters they created using doctl
. For example:
doctl k8s cluster create madhavi
> Notice: cluster is provisioning, waiting for cluster to be running
...............
> Notice: cluster created, fetching credentials
> Notice: adding cluster credentials to kubeconfig file found in "/home/hilary/.kube/config"
> Notice: setting current-context to do-sfo2-madhavi
doctl k8s cluster kubeconfig save madhavi
> Notice: adding cluster credentials to kubeconfig file found in "/home/hilary/.kube/config"
> Notice: setting current-context to do-sfo2-madhavi
kubectl --context do-sfo2-madhavi get nodes
NAME STATUS ROLES AGE VERSION
madhavi-default-pool-o770 NotReady <none> 42s v1.14.1
madhavi-default-pool-o771 NotReady <none> 50s v1.14.1
madhavi-default-pool-o77d NotReady <none> 32s v1.14.1
The doctl-config plug is different. Using it is a matter of software engineering (at least I think so). A clean solution vs a brittle one.
kubectl
uses the exec credential cached by doctl
under doctl
's config directory to auth, so that exec credential needs to be stored outside of the doctl
confinement. I could check whether I am running inside a snap and move just that credential in that circumstance, although I’m now embedding yet more knowledge about snaps into the doctl
code, which is going to create maintenance headaches down the road.
Without the doctl-config plug, I would also need to embed yet more snap-specific logic into the doctl code, assuming I’m not missing something. I experimented with not changing the value of $HOME
, but rather setting $KUBECONFIG
. Unfortunately, that doesn’t appear to work with the personal-files interface, which requires that the files start with $HOME/
. As I have to set $HOME
in the launcher for personal-files to work, that means I would have to override the config home directory for doctl
when running as a snap (to $SNAP_USER_DATA
?) without the doctl-config plug.
One the one hand, doctl
can use a doctl-config plug. It needs write access as it is managing the data in the config file. It’s a clean solution from a software engineering viewpoint, however, the config file, including the cached credential, is in the user’s home directory, which isn’t great.
On the other hand, lots of snap-specific logic can get injected into the doctl
code (yes, I’m doing my best to encapsulate it, but still). doctl
would, quite literally, have to override (exec credential) an override (doctl config home) of an override (HOME) in order for everything to work. And the most sensitive information, the cached exec credential, would still be in the user’s home directory. (Although the access token would not.) As software quality is a huge component of security, I came down on the side of the plug, but I’m not married to the decision by any means.
I’m also hoping there’s another alternative I’m not aware of.
Thanks!