The default configuration of the gatekeeper no-host-namespace policy (k8spsphostnamespace.constraints.gatekeeper.sh) appears to be blocking the deployment of monitoring and twistlock components in BigBang 1.13.1.
~ kubectl get k8spsphostnamespace.constraints.gatekeeper.sh -A no-host-namespace -o yaml...violations: - enforcementAction: deny kind: Pod message: 'Sharing the host namespace is not allowed: monitoring-monitoring-prometheus-node-exporter-zwp5h' name: monitoring-monitoring-prometheus-node-exporter-zwp5h namespace: monitoring - enforcementAction: deny kind: Pod message: 'Sharing the host namespace is not allowed: twistlock-defender-ds-5gsbq' name: twistlock-defender-ds-5gsbq namespace: twistlock...
Installed twistlock-defender using the twistlock UI. Successfully recreated reported twistlock-defender errors.
For example:
[no-host-namespace] Sharing the host namespace is not allowed: twistlock-defender-ds-rtwl5
Thanks for passing this along. We've moved gatekeeper exceptions into BB rather than the package so I don't think we'll merge that as is, but it gives us all the right exceptions we need.
@jennifer.kays it looks like we'll need 4 exceptions here:
hostNetworking: defenders need for ???, we should find the reason and document if possible
noHostNamespace: attached to above
restrictedTaint: defenders need to run on all nodes regardless of taint
allowedHostFilesystem: defenders need to mount files from the nodes to monitor them for security
Since all of these exceptions are for the defenders we might be able to use the new parameters.excludedResources value instead of excluding the whole ns. For that you'll just need namespace/resource name where resource name matches with the name that is shown in the violation message (supports regex). Example, although this likely isn't accurate to what is needed, twistlock/defenders-.* would add an exception for things named defender-xyzdefender-zxy in the twistlock ns.
Happy to sync if that gets confusing. We may have to just add the whole ns exception if user can modify the names of the created resources.
Thanks, @micah.nagel! I also noticed the hostNetworking and allowedHostFilesystem checks getting in the way of defender. I will have to look again for the restrictedTaint violation.
I've proven that excluding the twistlock namespace for noHostNamespace removes those violations. I'll go back and try it again with parameters.excludedResources.
One thing I've learned is I have to be patient when verifying results. I don't know if it's just twistlock, but the effects aren't showing up quickly!
For restrictedTaint you may not see it in normal testing since your nodes likely don't have taint. If you were to add taint to a node (see this doc) you should find that the defenders will not try to schedule on that node. Since the defenders are doing security monitoring for us we want them on every node regardless of status.
I haven't tested this one myself, but the way the violation is setup it would block Twistlock Defenders from that node, and we do want them.