During the workshop you went through the OpenShift developer experience starting from software development using Quarkus and odo, moving on to automating build and deployment using Tekton pipelines and finally using GitOps for production deployments.
Now it’s time to add another extremely important piece to the setup: enhancing application security in a containerized world. Using Red Hat Advanced Cluster Security for Kubernetes, of course!
Install the Advanced Cluster Security for Kubernetes operator from the OperatorHub:
Manual
Red Hat recommends installing the Red Hat Advanced Cluster Security for Kubernetes Operator in the rhacs-operator namespace. This will happen by default..
You must install the ACS Central instance in its own project and not in the rhacs-operator and openshift-operator projects, or in any project in which you have installed the ACS Operator!
apiVersion: platform.stackrox.io/v1alpha1
kind: Central
metadata:
name: stackrox-central-services
namespace: stackrox
spec:
monitoring:
openshift:
enabled: true
central:
notifierSecretsEncryption:
enabled: false
exposure:
loadBalancer:
enabled: false
port: 443
nodePort:
enabled: false
route:
enabled: true
telemetry:
enabled: true
db:
isEnabled: Default
persistence:
persistentVolumeClaim:
claimName: central-db
resources:
limits:
cpu: 2
memory: 6Gi
requests:
cpu: 500m
memory: 1Gi
persistence:
persistentVolumeClaim:
claimName: stackrox-db
egress:
connectivityPolicy: Online
scannerV4:
db:
persistence:
persistentVolumeClaim:
claimName: scanner-v4-db
indexer:
scaling:
autoScaling: Disabled
maxReplicas: 2
minReplicas: 1
replicas: 1
matcher:
scaling:
autoScaling: Disabled
maxReplicas: 2
minReplicas: 1
replicas: 1
scannerComponent: Default
scanner:
analyzer:
scaling:
autoScaling: Disabled
maxReplicas: 2
minReplicas: 1
replicas: 1
After the deployment has finished (Status Conditions: Deployed, Initialized
in the Operator view on the Central tab), it can take some time until the application is completely up and running. One easy way to check the state, is to switch to the Developer console view on the upper left. Then make sure you are in the stackrox project and open the Topology map. You’ll see the three deployments of the Central instance:
Wait until all Pods have been scaled up properly.
Verify the Installation
Switch to the Administrator console view again. Now to check the installation of your Central instance, access the ACS Portal:
If you access the details of your Central instance in the Operator page you’ll find the complete commandline using oc
to retrieve the password from the secret under Admin Credentials Info
. Just sayin… ;)
This will get you to the ACS Portal, accept the self-signed certificate and login as user admin with the password from the secret.
Now you have a Central instance that provides the following services in an RHACS setup:
The application management interface and services. It handles data persistence, API interactions, and user interface access. You can use the same Central instance to secure multiple OpenShift or Kubernetes clusters.
Scanner, which is a vulnerability scanner for scanning container images. It analyzes all image layers for known vulnerabilities from the Common Vulnerabilities and Exposures (CVEs) list. Scanner also identifies vulnerabilities in packages installed by package managers and in dependencies for multiple programming languages.
To actually do and see anything you need to add a SecuredCluster (be it the same or another OpenShift cluster). For effect go to the ACS Portal, the Dashboard should by pretty empty, click on either of the Compliance link in the menu to the left, lots of zero’s and empty panels, too.
This is because you don’t have a monitored and secured OpenShift cluster yet.
Now we’ll add your OpenShift cluster as Secured Cluster to ACS.
First, you have to generate an init bundle which contains certificates and is used to authenticate a SecuredCluster to the Central instance, regardless if it’s the same cluster as the Central instance or a remote/other cluster.
We are using the API to create the init bundle in this workshop, because if we use the Web Terminal we can’t upload and downloaded file to it. For the steps to create the init bundle in the ACS Portal see the appendix.
Let’s create the init bundle using the ACS API on the commandline:
Go to your Web Terminal (if it timed out just start it again), then paste, edit and execute the following lines:
<central_url>
with the base URL of your ACS portal (without ‘https://’ e.g. central-stackrox.apps.cluster-cqtsh.cqtsh.example.com)export ROX_ENDPOINT=<central_url>:443
export PASSWORD=<password>
export DATA={\"name\":\"my-init-bundle\"}
curl
command against the API to create the init bundle using the variables set abovecurl -k -o bundle.json -X POST -u "admin:$PASSWORD" -H "Content-Type: application/json" --data $DATA https://${ROX_ENDPOINT}/v1/cluster-init/init-bundles
cat bundle.json | jq -r '.kubectlBundle' > bundle64
base64 -d bundle64 > kube-secrets.bundle
You should now have these two files in your Web Terminal session: bundle.json
and kube-secrets.bundle
.
The init bundle needs to be applied to all OpenShift clusters you want to secure and monitor.
As said, you can create an init bundle in the ACS Portal, download it and apply it from any terminal where you can run oc
against your cluster. We used the API method to show you how to use it and to enable you to use the Web Terminal.
For this workshop we run Central and SecuredCluster on one OpenShift cluster. E.g. we monitor and secure the same cluster the central services live on.
Apply the init bundle
Again in the web terminal:
oc create -f kube-secrets.bundle -n stackrox
pointing to the init bundle you downloaded from the Central instance or created via the API as above.secret/collector-tls created
secret/sensor-tls created
secret/admission-control-tls created
You are ready to install the SecuredClusters instance, this will deploy the secured cluster services:
https://central-stackrox.apps.<DOMAIN>
the endpoint is central-stackrox.apps.<DOMAIN>:443
.Now go to your ACS Portal again, after a couple of minutes you should see your secured cluster under Platform Configuration->Clusters. Wait until all Cluster Status indicators become green.
To enable scanning of images in your Quay registry, you’ll have to configure an Integration with valid credentials, so this is what you’ll do.
Now, create a new Integration:
https://quay-quay-quay.apps.<DOMAIN>
(replace domain if required)