Lab Exercise 5.5
Hello,
I'm a little confused by Lab 5.5, related to Pod Security Policy. I'm hoping someone has been through it already and can point out where I've gone awry.
From my understanding, the lab would rely on the PSP controller being active, but the standard lab cluster setup doesn't activate the controller, as this would block all pod creation. Adding the controller to --enable-admission-controllers on the apiserver seems to create the desired behaviour, although the policy in nopriv.yaml is never bound to a user/serviceaccount in the lab, so I'm not clear how this is expected to work.
The example with the mariadb image is also confusing. If I follow the example, the pod is failing to start because MariaDB needs an environment variable, either specifying the root password, or allowing operation with no password. The following command will start MariaDB in the lab, independent of whether the pod security policy exists:kubectl run mariadb --image=mariadb --env=MYSQL_ALLOW_EMPTY_PASSWORD=true
I think I'm missing something fundamental on this lab; perhaps I've missed a setup step or similar. Does anyone have any advice?
Thanks in advance
Comments
-
@Hatofmonkeys The lab pdf attachment has been removed from your post, as the forum is public, while the lab material is paid/copyrighted and should not be attached to forum posts. Instructors moderating the forum have access to the course content, and will assist you. Referencing the chapter/lab number, and a section or step number, along with the issue encountered, is sufficient context when asking for help. Thank you!
0 -
@fcioanca Thanks, I'd presumed the forum was private.
0 -
@Hatofmonkeys Anyone can see the posts, but you need to log in with LF ID to be able to post.
0 -
Hello,
Thanks for getting back to me.
In the strictest sense, the expected inputs/outputs of the lab deviate at step 10. The expected output is that the pod is running, however the observed output is that the pod immediately enters CrashLoopBackoff.
As mentioned above, this can be remedied by supplying environment variables to the MariaDB container, however I believe the intent of the lab is to illustrate how Pod Security Policies work, and not how to use
kubectl logsand environment variables, so I think I've misunderstood.Regarding cluster setup, I am using two Ubuntu 18.04 vbox servers, installed via the k8sMaster/k8sSecond scripts in LFS260/SOLUTIONS/s_04/ , which in turn call out to
kubeadm init.
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
osboxes Ready master 5d22h v1.19.0 192.168.86.54 Ubuntu 18.04.3 LTS 4.15.0-130-generic docker://19.3.6
osboxes2 Ready 5d22h v1.19.0 192.168.86.56 Ubuntu 18.04.3 LTS 4.15.0-130-generic docker://19.3.6As also mentioned above, this install creates an apiserver static pod with --enable-admission-plugins=NodeRestriction . I was able to add the PSP controller successfully to the apiserver command line, and validate the correct working of PSPs, but my actions seemed to deviate a long way from the steps in the lab.
Thanks
0 -
Hi @Hatofmonkeys,
From your output it seems your Node IP addresses are 192.168.86.54 and 192.168.86.56.
If you are using Calico, and it is configured with the default Pod network 192.168.0.0/16, then you may be running into DNS issues with your cluster. The Node IP addresses should not overlap with the Pod network.
The fix is to either provision your VMs with different IP addresses, which would not overlap the default Pod network, or to leave the VM IPs alone but reconfigure Calico and the
kubeadm initcommand with a different private Pod network.Regards,
-Chris0 -
Hi Chris,
Thanks for the note; in my install Calico is using a pod CIDR of 192.169.0.0/16 (although k8s itself seems to remove the supernet /16 and return to the classful /24) to avoid the conflict with the lan's /16. From
kubectl describe node:System Info:
Machine ID: d34d8283f3ec49858389e19b8bf0746f
System UUID: 9D4CEB92-A203-6F41-B01C-E37296F8B745
Boot ID: 21dd4a28-ed35-4151-bb3f-146171b75d22
Kernel Version: 4.15.0-130-generic
OS Image: Ubuntu 18.04.3 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://19.3.6
Kubelet Version: v1.19.0
Kube-Proxy Version: v1.19.0
PodCIDR: 192.169.0.0/24
PodCIDRs: 192.169.0.0/24As an aside, if you ever do set Calico up with an overlapping pod CIDR of your nodes' gateway network, it routes all outbound traffic to the IP tunnel device and nothing can get in or out from your k8s nodes. Fun times.
Thanks
0 -
Hi Hatofmonkeys, I exercised 5.5 as below.
Before 4, I enabled Pod Security policy.
- Add PodSecurityPolicy to --enable-admission-plugins argument in /etc/kubernetes/manifests/kube-apiserver.yaml.
- kill kube-apiserver process.
Instead of kubectl create deployment, I executed
kubectl run mariadb --image=mariadb --env=MYSQL_ALLOW_EMPTY_PASSWORD=trueas you pointed out.Instead of result of 5, I got the following.
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
mariadb 0/1 CreateContainerConfigError 0 6sI am not sure this follows contents creator's intention.
Thanks,
Hidekazu Nakamura0 -
Hi Hidekazu,
If you enable the PodSecurityPolicy controller without enabling any policies (and binding those policies to your users/serviceaccounts) then no pods will be able to start in your cluster.
Once you've enabled the PSP controller admission plugin you will need to create a policy and bind it to your user (or to the serviceaccount of the replicaset if you're using a deployment). This is outlined at https://kubernetes.io/docs/concepts/policy/pod-security-policy/#enabling-pod-security-policies .
With these steps in place, plus the specified environment variable when launching mariadb, you should be able to observe the mariadb container being allowed/disallowed depending on the runAsUser PSP setting mentioned in the lab. I believe this is the intent of the lab, although I am very interested to hear from the lab's author as to whether I've misunderstood.
Regards
1 -
@serewicz If PSPs have been deprecated by the community (likely in favor of OPA Gatekeeper based on the chatter I've been seeing), does this have any effect on the exam material? If you can't answer because of the firewalling between training and exam teams, that's fine, I just want to make sure I understand CNCF's position on PSPs for CKS going forward.
0 -
@serewicz I appreciate the answer. Also, just saw the latest version of the PSP lab, really helps with the issues I was having with that lab. Thanks!
0 -
Although PodSecurityPolicy might be deprecated I too found 5.5 step 14 and 15 a bit cryptic.
Also the replicaset error message doesn't really tell what is wrong:Error creating: pods10"db-two-6fd7fc85c9-" is forbidden: PodSecurityPolicy: unable to admit pod: []
@Hatofmonkeys brought me on the right track and I found the solution by adding a new serviceAccount
dbtwoto the deployment object and creating a new role and rolebinding.kind: Role metadata: name: run-db-two namespace: default rules: - apiGroups: ['policy'] resources: ['podsecuritypolicies'] verbs: ['use'] resourceNames: - no-priv
apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: dbtwobinding roleRef: kind: ClusterRole name: run-db-two apiGroup: rbac.authorization.k8s.io subjects: - kind: ServiceAccount name: dbtwo namespace: default
0
Categories
- All Categories
- 175 LFX Mentorship
- 175 LFX Mentorship: Linux Kernel
- 744 Linux Foundation IT Professional Programs
- 372 Cloud Engineer IT Professional Program
- 168 Advanced Cloud Engineer IT Professional Program
- 72 DevOps IT Professional Program - Discontinued
- 3 DevOps & GitOps IT Professional Program
- 98 Cloud Native Developer IT Professional Program
- 39 Express Training Courses & Microlearning
- 34 Express Courses - Discussion Forum
- 7.6K Training Courses & Learning Paths
- AI & ML Training
- Blockchain & Decentralized Identity Training
- Cloud & Containers Training
- Cybersecurity Training
- DevOps & Site-Reliability Training
- Linux Kernel Development Training
- Networking Training
- Open Source Best Practice Training
- System Administration Training
- System Engineering Training
- Web & Application Development Training
- 55 LFD102 Class Forum
- 261 LFD103 Class Forum
- 2 LFD103-JP クラス フォーラム
- 2 LFD114 Class Forum
- 56 LFD121 Class Forum
- 4 LFD123 Class Forum
- 3 LFD125 Class Forum
- 5 LFD137 Class Forum
- 2 LFD140 Class Forum
- 4 LFD210-CN Class Forum
- 2 LFD221 Class Forum
- 26 LFD254 Class Forum
- 764 LFD259 Class Forum
- 679 LFS101 Class Forum
- 3 LFS114 Class Forum
- 6 LFS118 Class Forum
- 3 LFS120 Class Forum
- 2 LFS140 Class Forum
- 13 LFS142 Class Forum
- 10 LFS144 Class Forum
- 8 LFS146 Class Forum
- 30 LFS148 Class Forum
- 6 LFS157 Class Forum
- 179 LFS158 Class Forum
- 2 LFS158-JP クラス フォーラム
- 19 LFS162 Class Forum
- 4 LFS180 Class Forum
- 3 LFS184 Class Forum
- 162 LFS207 Class Forum
- 3 LFS207-DE-Klassenforum
- 4 LFS207-JP クラス フォーラム
- 61 LFS241 Class Forum
- 52 LFS242 Class Forum
- 42 LFS243 Class Forum
- 19 LFS244 Class Forum
- 9 LFS245 Class Forum
- 3 LFS246 Class Forum
- 2 LFS248 Class Forum
- 179 LFS250 Class Forum
- 4 LFS250-JP クラス フォーラム
- 166 LFS253 Class Forum
- 5 LFS255 Class Forum
- 19 LFS256 Class Forum
- 3 LFS257 Class Forum
- 1.4K LFS258 Class Forum
- 13 LFS258-JP クラス フォーラム
- 151 LFS260 Class Forum
- 165 LFS261 Class Forum
- 26 LFS267 Class Forum
- 28 LFS268 Class Forum
- 39 LFS269 Class Forum
- 13 LFS270 Class Forum
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 768 Linux Distributions
- 81 Debian
- 67 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 105 Mobile Computing
- 18 Android
- 72 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 928 Programming and Development
- 310 Kernel Development
- 600 Software Development
- 969 Software
- 361 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 75 All In Program
- 75 All In Forum
- 25 LFC110 Class Forum - Discontinued
- 2 LFS112 Class Forum - Discontinued
- 22 LFS151 Class Forum - Discontinued
- 1 LFS166 Class Forum - Discontinued
- 9 LFS167 Class Forum - Discontinued
- 4 LFS170 Class Forum - Discontinued
- 1 LFS171 Class Forum - Discontinued
- 3 LFS178 Class Forum - Discontinued
- 736 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム - Discontinued
- 301 LFS211 Class Forum - Discontinued
- 55 LFS216 Class Forum - Discontinued
- 2 LFS251 Class Forum - Discontinued
- 1 LFS254 Class Forum - Discontinued
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 2 LFS272-JP クラス フォーラム - Discontinued
- 202 LFS272 Class Forum - Discontinued
- 1 LFS274 Class Forum - Discontinued
- 4 LFS281 Class Forum - Discontinued
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)


