|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * microshift_storage/understanding-persistent-storage-microshift.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="microshift-checking-pods-mismatch_{context}"] |
| 7 | += Checking the pods for mismatch |
| 8 | + |
| 9 | +Check if the pods have a mismatch. Update the SELinux context if a mismatch is found by using the following procedure. |
| 10 | + |
| 11 | +[IMPORTANT] |
| 12 | +==== |
| 13 | +* Replace `_<pod_name_A>_` with the name of the first pod in the following procedure. |
| 14 | +* Replace `_<pod_name_B>_` with the name of the second pod in the following procedure. |
| 15 | +* Replace `_<PVC_mountpoint>_` with the mount point within the pods. |
| 16 | +==== |
| 17 | + |
| 18 | +.Procedure |
| 19 | + |
| 20 | +. List the mount point within the first pod by running the following command: |
| 21 | ++ |
| 22 | +[source,terminal] |
| 23 | +[subs="+quotes"] |
| 24 | +---- |
| 25 | +$ oc get pods -n _<pod_name_A>_ -ojsonpath='{.spec.containers[*].volumeMounts[*].mountPath}' <1> |
| 26 | +---- |
| 27 | +<1> Replace `_<pod_name_A>_` with the name of the first pod. |
| 28 | ++ |
| 29 | +.Example output |
| 30 | +[source,terminal] |
| 31 | +---- |
| 32 | +/files /var/run/secrets/kubernetes.io/serviceaccount |
| 33 | +---- |
| 34 | +. List the mount point within the second pod by running the following command: |
| 35 | ++ |
| 36 | +[source,terminal] |
| 37 | +[subs="+quotes"] |
| 38 | +---- |
| 39 | +$ oc get pods -n _<pod_name_B>_ -ojsonpath='{.spec.containers[*].volumeMounts[*].mountPath}' <1> |
| 40 | +---- |
| 41 | +<1> Replace `_<pod_name_B>_` with the name of the second pod. |
| 42 | ++ |
| 43 | +.Example output |
| 44 | +[source,terminal] |
| 45 | +---- |
| 46 | +/files /var/run/secrets/kubernetes.io/serviceaccount |
| 47 | +---- |
| 48 | +. Check the context and permissions inside the first pod by running the following command: |
| 49 | ++ |
| 50 | +[source,terminal] |
| 51 | +[subs="+quotes"] |
| 52 | +---- |
| 53 | +$ oc rsh _<pod_name_A>_ ls -lZah _<PVC_mountpoint>_ <1> |
| 54 | +---- |
| 55 | +<1> Replace `_<pod_name_A>_` with the name of the first pod and replace `_<PVC_mountpoint>_` with the mount point within the first pod. |
| 56 | ++ |
| 57 | +.Example output |
| 58 | +[source,terminal] |
| 59 | +---- |
| 60 | +total 12K |
| 61 | +dr-xr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c398,c806 40 Feb 17 13:36 . |
| 62 | +dr-xr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c398,c806 40 Feb 17 13:36 .. |
| 63 | +[...] |
| 64 | +---- |
| 65 | +. Check the context and permissions inside the second pod by running the following command: |
| 66 | ++ |
| 67 | +[source,terminal] |
| 68 | +[subs="+quotes"] |
| 69 | +---- |
| 70 | +$ oc rsh _<pod_name_B>_ ls -lZah _<PVC_mountpoint>_ <1> |
| 71 | +---- |
| 72 | +<1> Replace `_<pod_name_B>_` with the name of the second pod and replace `_<PVC_mountpoint>_` with the mount point within the second pod. |
| 73 | ++ |
| 74 | +.Example output |
| 75 | +[source,terminal] |
| 76 | +---- |
| 77 | +total 12K |
| 78 | +dr-xr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c15,c25 40 Feb 17 13:34 . |
| 79 | +dr-xr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c15,c25 40 Feb 17 13:34 .. |
| 80 | +[...] |
| 81 | +---- |
| 82 | +. Compare both the outputs to check if there is a mismatch of SELinux context. |
| 83 | +. When there is a mismatch of the SELinux content, create a new SCC and assign it to both PODs. To create a SCC see link: https://docs.openshift.com/container-platform/4.15/authentication/managing-security-context-constraints.html#security-context-constraints-creating_configuring-internal-oauth[Creating security context constraints]. |
| 84 | +. Update the SELinuxContext as shown in the following example: |
| 85 | ++ |
| 86 | +.Example output |
| 87 | +[source,terminal] |
| 88 | +---- |
| 89 | + [...] |
| 90 | + securityContext:privileged |
| 91 | + seLinuxOptions:MustRunAs |
| 92 | + level: "s0:cXX,cYY" |
| 93 | + [...] |
| 94 | +---- |
| 95 | +
|
| 96 | +.Verification |
| 97 | +
|
| 98 | +. Verify that the same SCC is assigned to the first pod by running the following command: |
| 99 | ++ |
| 100 | +[source,terminal] |
| 101 | +[subs="+quotes"] |
| 102 | +---- |
| 103 | +$ oc describe pod _<pod_name_A>_ |grep -i scc <1> |
| 104 | +---- |
| 105 | +<1> Replace `_<pod_name_A>_` with the name of the first pod. |
| 106 | ++ |
| 107 | +.Example output |
| 108 | +[source,terminal] |
| 109 | +---- |
| 110 | +openshift.io/scc: restricted |
| 111 | +---- |
| 112 | +. Verify that the same SCC is assigned to first second pod by running the following command: |
| 113 | ++ |
| 114 | +[source,terminal] |
| 115 | +[subs="+quotes"] |
| 116 | +---- |
| 117 | +$ oc describe pod _<pod_name_B>_ |grep -i scc <1> |
| 118 | +---- |
| 119 | +<1> Replace `_<pod_name_B>_` with the name of the second pod. |
| 120 | ++ |
| 121 | +.Example output |
| 122 | +[source,terminal] |
| 123 | +---- |
| 124 | +openshift.io/scc: restricted |
| 125 | +---- |
| 126 | +. Verify that the same SELinux label is applied to first pod by running the following command: |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +[subs="+quotes"] |
| 130 | +---- |
| 131 | +$ oc exec _<pod_name_A>_ -- ls -laZ _<PVC_mountpoint>_ <1> |
| 132 | +---- |
| 133 | +<1> Replace `_<pod_name_A>_` with the name of the first pod and replace `_<PVC_mountpoint>_` with the mount point within the first pod. |
| 134 | ++ |
| 135 | +.Example output |
| 136 | +[source,terminal] |
| 137 | +---- |
| 138 | +total 4 |
| 139 | +drwxrwsrwx. 2 root 1000670000 system_u:object_r:container_file_t:s0:c10,c26 19 Aug 29 18:17 . |
| 140 | +dr-xr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c10,c26 61 Aug 29 18:16 .. |
| 141 | +-rw-rw-rw-. 1 1000670000 1000670000 system_u:object_r:container_file_t:s0:c10,c26 29 Aug 29 18:17 test1 |
| 142 | +[...] |
| 143 | +---- |
| 144 | +. Verify that the same SELinux label is applied to second pod by running the following command: |
| 145 | ++ |
| 146 | +[source,terminal] |
| 147 | +[subs="+quotes"] |
| 148 | +---- |
| 149 | +$ oc exec _<pod_name_B>_ -- ls -laZ _<PVC_mountpoint>_ <1> |
| 150 | +---- |
| 151 | +<1> Replace `_<pod_name_B>_` with the name of the second pod and replace `_<PVC_mountpoint>_` with the mount point within the second pod. |
| 152 | ++ |
| 153 | +.Example output |
| 154 | +[source,terminal] |
| 155 | +---- |
| 156 | +total 4 |
| 157 | +drwxrwsrwx. 2 root 1000670000 system_u:object_r:container_file_t:s0:c10,c26 19 Aug 29 18:17 . |
| 158 | +dr-xr-xr-x. 1 root root system_u:object_r:container_file_t:s0:c10,c26 61 Aug 29 18:16 .. |
| 159 | +-rw-rw-rw-. 1 1000670000 1000670000 system_u:object_r:container_file_t:s0:c10,c26 29 Aug 29 18:17 test1 |
| 160 | +[...] |
| 161 | +---- |
0 commit comments