Security - KubeConfig Flashcards
How can you call a KubeConfig-File with kubectl?
kubectl get pods –kubeconfig config
What are contents of KubeConfig?
-- server my-kube-playground:6443 --client-key admin.key --client-certificate admin.crt --certificate-authority ca.crt
Where does the kubectl command look by default for a kubeconfig file?
$HOME/.kube/config
What is the structure of a KubeConfig file?
- Clusters (various clusters, you need access to)
- Contexts (define which user account will be accessed with which cluster, Dev@Google)
- Users (user accounts with which you have access to these clusters)
How does a KubeConfig file look?
apiVersion: v1 kind: Config current-context: dev-user@google clusters: - name: my-kube-playground cluster: certificate-authority: ca.crt server; https://my-kube-playground:6443 contexts: name: my-kube-admin@my-kube-playground context: cluster: my-kube-playground user: my-kube-admin users: - name: my-kube-admin user: client-certificate: admin.crt client-key: admin.key
What is the ‘current-context’ in a KubeConfig used for?
- specifies the default context that should be user?
How can we view the current used KubeConfig file?
kubectl config view
How do you update your current context?
kubectl config user-context prod-user@production
Can you configure a context to switch to a particular namespace?
Yes
Contexts section in the KubeConfig file can take a field
context.namespace
When you switch to that context, youre automatically in that namespace
With what command can you see config files under /.kube/
with ‘ls -a’
How can you view a environment variable on linux?
echo $VARIABLE
like
echo $HOME
In linux how can you copy a file from place a to b?
cp my-kube-config ~/.kube/config
In linux how can you rename a file?
mv oldfilename newfilename