Kubernetes Security Primitives
Kubernetes Security Primitives
Kubernetes Security Primitives
Expanding on our discussion about securing the Kubernetes cluster, we’ll take a look at
service accounts and user authentication. Also in this lesson, we will create a
workstation for you to administer your cluster without logging in to the Kubernetes
master server.
kubectl get sa
The YAML for a busybox pod using the jenkins service account:
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: default
spec:
serviceAccountName: jenkins
containers:
- image: busybox:1.28.4
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: busybox
restartPolicy: Always
cat ~/.kube/config
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: web
name: service-reader
rules:
- apiGroups: [""]
verbs: ["get", "list"]
resources: ["services"]
Create a RoleBinding:
kubectl proxy
curl localhost:8001/api/v1/namespaces/web/services
The YAML for a pod that includes a curl and proxy container:
apiVersion: v1
kind: Pod
metadata:
name: curlpod
namespace: web
spec:
containers:
- image: tutum/curl
command: ["sleep", "9999999"]
name: main
- image: linuxacademycontent/kubectl-proxy
name: proxy
restartPolicy: Always
Create the pod that will allow you to curl directly from the container:
curl localhost:8001/api/v1/persistentvolumes