|
| 1 | +# Check and Troubleshooting |
| 2 | + |
| 3 | +## How to check Integrity Shield working |
| 4 | + |
| 5 | +### Check Installation |
| 6 | + |
| 7 | +To check if Integrity Shield is correctly deployed, you can check Pod status and webhook existence like the following. |
| 8 | + |
| 9 | +If `integrity-shield-server` Pod is Running and a WebhookConfiguration is there, Integrity Shield is installed and working. |
| 10 | + |
| 11 | + |
| 12 | +``` |
| 13 | +$ oc get pod -n integrity-shield-operator-system |
| 14 | +NAME READY STATUS RESTARTS AGE |
| 15 | +integrity-shield-operator-controller-manager-7df9cfffd-tzq2f 1/1 Running 0 23m |
| 16 | +integrity-shield-server-8469845dd-98bld 2/2 Running 0 22m |
| 17 | +
|
| 18 | +$ oc get mutatingwebhookconfiguration |
| 19 | +NAME WEBHOOKS AGE |
| 20 | +ishield-webhook-config 1 22m |
| 21 | +``` |
| 22 | + |
| 23 | +### Check Integrity Shield Events |
| 24 | + |
| 25 | +Integrity Shield reports all events that were denied by Integrity Shield itself. |
| 26 | + |
| 27 | +You can see all denied requests as Kubernetes Event like below. |
| 28 | + |
| 29 | +``` |
| 30 | +$ oc get event -n secure-ns --field-selector type=IntegrityShield |
| 31 | +
|
| 32 | +LAST SEEN TYPE REASON OBJECT MESSAGE |
| 33 | +27s IntegrityShield no-signature configmap/test-cm [IntegrityShieldEvent] Result: deny, Reason: "Signature verification is required for this request, but no signature is found. Please attach a valid signature to the annotation or by a ResourceSignature.", Request: {"kind":"ConfigMap","name":"test-cm","namespace":"secure-ns","operation":"CREATE","request.uid":"cfea7d34-0bf0-4e6a-9b59-e53290e02e67","scope":"Namespaced","userName":"kubernetes-admin"} |
| 34 | +``` |
| 35 | + |
| 36 | +This is an example of ConfigMap request, so the event is reported in the same namespace as ConfigMap namespace. |
| 37 | + |
| 38 | +If a request of Cluster-scoped resource such as ClusterRole is denied by Integrity Shield, the event will be created in the same namespace as Integrity Shield. |
| 39 | + |
| 40 | +To check all denied events in your cluster, simply you can run the command below. |
| 41 | + |
| 42 | +``` |
| 43 | +$ oc get event --all-namespaces --field-selector type=IntegrityShield |
| 44 | +``` |
| 45 | + |
| 46 | +If you want to check not only denied events but also allowed events, they are logged in container log. Please see the next section. |
| 47 | + |
| 48 | + |
| 49 | +### Check RSP status |
| 50 | + |
| 51 | +Resource Signing Profile (RSP) defines what resource should be protected by Integrity Shield, so RSP status shows corresponding denied events if exist. |
| 52 | + |
| 53 | +You can check RSP status like the following. |
| 54 | + |
| 55 | +``` |
| 56 | +$ oc describe rsp -n secure-ns sample-rsp |
| 57 | +
|
| 58 | +... |
| 59 | +
|
| 60 | +Status: |
| 61 | + Deny Count: 1 |
| 62 | + Deny Summary: |
| 63 | + Count: 1 |
| 64 | + Group Version Kind: /v1, Kind=ConfigMap |
| 65 | + Latest Denied Events: |
| 66 | + Request: |
| 67 | + API Version: v1 |
| 68 | + Kind: ConfigMap |
| 69 | + Name: sample-cm |
| 70 | + Namespace: secure-ns |
| 71 | + Operation: CREATE |
| 72 | + User Name: kubernetes-admin |
| 73 | + Result: |
| 74 | + Message: Signature verification is required for this request, but no signature is found. Please attach a valid signature to the annotation or by a ResourceSignature. |
| 75 | + Timestamp: 2021-01-13 07:34:21 |
| 76 | +
|
| 77 | +``` |
| 78 | + |
| 79 | +### Check Integrity Verified Resources |
| 80 | + |
| 81 | +When you want to check what resources are verified with their signatures, you can use a script named [`list_signed_resources.sh `](../scripts/list_signed_resources.sh). |
| 82 | + |
| 83 | +This script shows you a list of resources that are verified by Integrity Shield, and you can use a short name for a kind argument like below. |
| 84 | + |
| 85 | +``` |
| 86 | +$ ./scripts/list_signed_resources.sh deployment |
| 87 | +--- Deployment --- |
| 88 | +NAMESPACE NAME SIGNER LAST_VERIFIED RSIG_UID |
| 89 | +secure-ns sample-deployment [email protected] 2021-01-20T07:28:09Z 2de4ea9e-7bfb-45fd-a730-ab866cfd4332 |
| 90 | +
|
| 91 | +$ ./scripts/list_signed_resources.sh cm |
| 92 | +--- ConfigMap --- |
| 93 | +NAMESPACE NAME SIGNER LAST_VERIFIED RSIG_UID |
| 94 | +secure-ns sample-cm [email protected] 2021-01-20T07:27:59Z ac31dd59-6f73-4958-a21a-df337fbf5d07 |
| 95 | +secure-ns sample-cm-2 [email protected] 2021-01-20T07:43:38Z 08dbcb7d-3055-4a84-8246-302510d9b76c |
| 96 | +``` |
| 97 | + |
| 98 | +Also, you can specify `all` as kind argument, but please note that this queries `kubectl get` API for all valid resource kinds. The output will be like following. |
| 99 | +``` |
| 100 | +$ ./scripts/list_signed_resources.sh all |
| 101 | +--- ConfigMap --- |
| 102 | +NAMESPACE NAME SIGNER LAST_VERIFIED RSIG_UID |
| 103 | +secure-ns sample-cm [email protected] 2021-01-20T07:27:59Z ac31dd59-6f73-4958-a21a-df337fbf5d07 |
| 104 | +secure-ns sample-cm-2 [email protected] 2021-01-20T07:43:38Z 08dbcb7d-3055-4a84-8246-302510d9b76c |
| 105 | +
|
| 106 | +--- Service --- |
| 107 | +NAMESPACE NAME SIGNER LAST_VERIFIED RSIG_UID |
| 108 | +secure-ns test-service [email protected] 2021-01-20T07:27:20Z null |
| 109 | +
|
| 110 | +--- Deployment --- |
| 111 | +NAMESPACE NAME SIGNER LAST_VERIFIED RSIG_UID |
| 112 | +secure-ns sample-deployment [email protected] 2021-01-20T07:28:09Z 2de4ea9e-7bfb-45fd-a730-ab866cfd4332 |
| 113 | +
|
| 114 | +--- ClusterRole --- |
| 115 | +NAMESPACE NAME SIGNER LAST_VERIFIED RSIG_UID |
| 116 | +- sample-sa-role [email protected] 2021-01-20T07:48:41Z aa63307a-a938-4efd-8d98-dd1f8b0442eb |
| 117 | +``` |
| 118 | + |
| 119 | + |
| 120 | +## Troubleshooting |
| 121 | + |
| 122 | +### Install issue |
| 123 | + |
| 124 | +If only operator Pod (`integrity-shield-operator-controller-xxxx-xxxx` by default) is running and there is no `integrity-shield-server-xxxx-xxxx` Pod, please check operator container log. |
| 125 | + |
| 126 | +If you see the log message like below, some required verification key secret are not ready. Once you deployed the secret there, installation will be started by operator. |
| 127 | + |
| 128 | +``` |
| 129 | +$ oc get pod -n integrity-shield-operator-system |
| 130 | +NAME READY STATUS RESTARTS AGE |
| 131 | +integrity-shield-operator-controller-manager-7df9cfffd-tzq2f 1/1 Running 0 2m |
| 132 | +
|
| 133 | +
|
| 134 | +$ oc logs deployment.apps/integrity-shield-operator-controller-manager |
| 135 | +
|
| 136 | +... |
| 137 | +
|
| 138 | +2021-01-13T09:06:15.279Z INFO controllers.IntegrityShield KeyRing secret "keyring-secret" does not exist. Skip reconciling. {"Request.Namespace": "integrity-shield-operator-system", "Request.Name": "integrity-shield-server"} |
| 139 | +2021-01-13T09:06:15.286Z INFO controllers.IntegrityShield KeyRing secret "keyring-secret" does not exist. Skip reconciling. {"Request.Namespace": "integrity-shield-operator-system", "Request.Name": "integrity-shield-server"} |
| 140 | +2021-01-13T09:06:15.299Z INFO controllers.IntegrityShield KeyRing secret "keyring-secret" does not exist. Skip reconciling. {"Request.Namespace": "integrity-shield-operator-system", "Request.Name": "integrity-shield-server"} |
| 141 | +``` |
| 142 | + |
| 143 | + |
| 144 | +### Uninstall issue |
| 145 | + |
| 146 | +Integrity Shield protects Integirty Shield itself, so uninstalling it should be done by some correct steps. |
| 147 | + |
| 148 | +Documents and some scripts in this repository provide automated ways to uninstall Integrity Shield, so basically you don't need to know the actual steps. |
| 149 | + |
| 150 | +But sometimes you might face a issue around uninstall due to some reasons, and you might not be able to uninstall it. |
| 151 | + |
| 152 | +In such a case, deleting `MutatingWebhookConfiguration` of IntegrityShield could solve the situation. |
| 153 | + |
| 154 | +Here is example steps of manual uninstall for Integrity Shield. |
| 155 | + |
| 156 | +``` |
| 157 | +$ oc delete mutatingwebhookconfiguration ishield-webhook-config |
| 158 | +mutatingwebhookconfiguration.admissionregistration.k8s.io "ishield-webhook-config" deleted |
| 159 | +
|
| 160 | +$ oc delete integrityshield integrity-shield-server -n integrity-shield-operator-system |
| 161 | +integrityshield.apis.integrityshield.io "integrity-shield-server" deleted |
| 162 | +
|
| 163 | +$ oc get pod -n integrity-shield-operator-system |
| 164 | +NAME READY STATUS RESTARTS AGE |
| 165 | +integrity-shield-operator-controller-manager-7df9cfffd-tzq2f 1/1 Running 0 23m |
| 166 | +``` |
| 167 | + |
| 168 | +After deleting IntegrityShield CR, the server Pod will be deleted (because CR is the owner). |
| 169 | + |
| 170 | +Once you successfully deleted server Pod, no blocking functions are working anymore, so you can delete all other resources if you want. |
| 171 | + |
| 172 | +### Unexpected Deny |
| 173 | + |
| 174 | +If your request has been denied in spite of non-protected resource, please check RSPs in the cluster. |
| 175 | + |
| 176 | +Basically, RSPs in a certain namespace can be used only for protection of resources in the namespace. |
| 177 | + |
| 178 | +However, RSPs in Integrity Shield namespace (`integrity-shield-operator-system` by default) can be used as something like global configuration, so it can define any namespace rule. |
| 179 | + |
| 180 | +To see all RSPs in your cluster, you can use a [list_rsp.sh ](../scripts/list_rsp.sh) (Use `jq` and `column` in the script) |
| 181 | + |
| 182 | +``` |
| 183 | +$ ./scripts/list_rsp.sh |
| 184 | +NAMESPACE NAME RULES TARGET_NAMESPACE |
| 185 | +integrity-shield-operator-system global-rsp {"protectRules":[{"match":[{"kind":"Service"}]}]} {"exclude":["kube-*"],"include":["*"]} |
| 186 | +secure-ns sample-rsp {"protectRules":[[{"match":[{"kind":"Pod"},{"kind":"ConfigMap"},{"kind":"Deployment"}]}]} secure-ns |
| 187 | +test-ns sample-clusterrole-rsp {"protectRules":[[{"match":[{"kind":"ClusterRole"}]}]} test-ns |
| 188 | +``` |
| 189 | + |
| 190 | +Additionally, if you are using ResourceSignature instead of annotation signature, you can list all ResourceSignatures in your cluster by a script [list_rsig.sh ](../scripts/list_rsig.sh) . |
| 191 | + |
| 192 | +This might be useful to solve some issues caused by mis-configured ResourceSignature. |
| 193 | + |
| 194 | +``` |
| 195 | +$ ./scripts/list_rsig.sh |
| 196 | +NAMESPACE NAME SIGNED_OBJECT SIGNED_TIME(UTC) |
| 197 | +secure-ns rsig-configmap-sample-cm kind=ConfigMap,name=sample-cm 2021-01-13T10:52:38Z |
| 198 | +test-ns rsig-deployment-sample-deployment kind=Deployment,name=sample-deployment 2021-01-13T10:53:27Z |
| 199 | +``` |
| 200 | + |
| 201 | + |
| 202 | +### Unexpected Allow |
| 203 | + |
| 204 | +If your request has been allowed unexpectedly, please check if Integrity Shield is correctly working in the cluster first. |
| 205 | +You can check it following [this](#check-installtion) . |
| 206 | + |
| 207 | +Also, mis-configured RSP might cause unexpected allow, so the script above ([list_rsp.sh](../scripts/list-rsp.sh)) might be useful to check RSP configurations. |
| 208 | + |
| 209 | +If Integirty Shield and RSPs are correctly set up in the cluster, server container of integrity-shield-server Pod might log unexpected error, this should not be happened though. |
| 210 | + |
| 211 | +In this case, reporting issue with your log will be great help for us to improve Integrity Shield even more. We would really appreciate you if you could report any issue. |
| 212 | + |
0 commit comments