This repository contains the Ansible playbooks and roles for validating an OpenShift cluster.
The playbook performs the following opinionated validations:
oAuth server metadata |
verify the oauth server’s |
|
verify oAuth server issuer metadata is as expected. |
||
cluster version |
verify |
|
cluster operators |
verify all |
|
machine config pools |
verify all nodes belong to a |
|
machines |
verify all machines are in |
|
verify number of machines and nodes is equal. |
||
nodes |
verify number of control nodes is as specified. |
|
verify number of worker nodes is as specified. |
||
verify all nodes are in |
||
verify all control nodes are unschedulable. Reference |
||
verify |
||
verify cpu and memory metrics for nodes are collected. Reference |
||
certificate signing request |
verify no |
|
wildcard DNS and certificate |
verify default ingress DNS domain is as specified. |
|
verify wildcard DNS domain |
||
verify ingress serving certificate Subject Alternative Names include th wildcard DNS hostname |
||
CoreDNS |
verify DNS lookup of service A record. |
|
verify DNS lookup of service SRV record. |
||
NTP |
verify ntp is synchronized on all nodes. |
|
kubeadmin user |
verify |
|
oauth |
verify |
|
verify |
||
verify at least one identity provider is configured. |
||
verify ldap identity provider uses secured connection. |
||
verify console login banner is configured. |
||
CLI motd |
verify motd is configured. |
|
etcd |
verify etcd is healthy. |
|
verify performance of disk hosting etcd. |
||
verify etcd data is encrypted. |
||
verify etcd data encryption is |
||
verify etcd data encryption is completed. |
||
TLS security profile |
verify |
|
verify |
||
verify |
||
verify |
||
verify |
||
verify |
||
audit profile |
verify audit profile is configured. |
|
project self provisioner |
verify project self provisioner is not allowed for authenticated users. |
|
project request template |
verify project request template is configured. |
|
verify project request template defines: Project, LimitRange, ResourceQuota, NetworkPolicy. |
||
storage class |
verify default storage class is configured. |
|
verify only one default storage class is configured. |
||
verify default storage class is as specified. |
||
operator hub |
verify default |
|
verify at least one |
||
verify all |
||
verify |
||
verify all |
||
verify all |
||
monitoring stack |
verify user workload monitoring is enabled. |
|
verify cluster monitoring stack is using persistent volume. |
||
verify user workload monitoring stack is using persistent volume. |
||
verify AlertManager has at least one receiver configured |
||
verify alert notifications are sent to external system |
||
logging stack |
verify openshift logging operator is deployed. |
|
verify |
||
verify |
||
verify |
||
image controller config |
verify image registries whitelist is configured. |
|
verify insecure image registries are not allowed. |
||
verify import from insecure image registries are not allowed. |
||
verify |
||
openshift image registry |
verify image registry is not using |
|
pods |
verify all pods are in |
|
verify no pod in |
||
verify pods with too many restarts. |
||
verify |
||
verify cpu and memory metrics for pods are collected. |
The playbook is base on this OpenShift Learning path, it:
-
stateful application:
-
deploys
mongodbStatefulSet andnamegenDeployment. -
exposes the
namegenservice externally via Route. -
creates database, collection, and document in mongodb.
-
stimulate failure by killing
mongodbandnamegebpods; OpenShift will restart the pods. -
compare documents in mongodb before and after failure.
-
deletes the resources created.
-
-
stateless application:
-
configure Role and RoleBinding to allow
getandlistaccess o Pods and ConfigMaps. -
deploys
ose-toolsimage to runocandcurlcommands against OpenShift API server, to get/list Pods, ConfigMaps, Secrets and Nodes.
-
Successful playbook execution confirms the following:
-
create/delete OpenShift resources (Namespace, Secret, ConfigMap, PersistentVolumeClaim, PersistentVolume, NetworkPolicy, StatefulSet, Deployment, Job, Service, Route, Role, RoleBinding, etc).
-
default storage class is configured.
-
dynamic provisioning of persistent volume.
-
persistent volume for storing stateful data; no data loss when application pods failed.
-
consuming OpenShift Secret/ConfigMap ss volume or environment variables.
-
service discovery via CoreDNS.
-
ingress and egress network policies to allow only necessary traffic, denies the rest.
-
externally exposed application service is accessible.
-
RBAC to allow access to specific OpenShift resources from within the container.
|
Important
|
The playbook does not deploy the application with common best practices:
|
The playbook estimates the capacity of the cluster using OpenShift Cluster Capacity Tool. The tool estimates the number of pods that can be scheduled on the cluster with this podSpec.
System |
|
Ansible content collections |
|
Python modules |
|
OpenShift cluster |
|
Instead of installing the dependencies on the host, use the execution environment image quay.io/bkhoo/ee-openshift-validation:1.0 to run the playbooks with ansible-navigator run command line.
See this document for the steps to build execution environment image.
-
Create a YAML file with the following settings:
--- kubeconfig_file: /home/bkhoo/.kube/config cluster_version: 4.15.8 cluster_ingress_domain: apps.cluster-12345.examle.com ingress_ip: - 192.168.192.168 control_nodes: 3 worker_nodes: 3 default_storage_class: ocs-external-storagecluster-ceph-rbd # min_access_token_max_age_seconds: 600 # playbook default # min_access_token_inactivity_timeout: 600 # playbook default # etc_encryption_type: aesgcm # playbook default # allowed_registries: # playbook default # - quay.io # - registry.redhat.io # - registry.access.redhat.com # - image-registry.openshift-image-registry.svc:5000 # acceptable_audit_profiles: # playbook default # - WriteRequestBodies # - AllRequestBodies # project_template_objects: # playbook default # - Project # - LimitRange # - ResourceQuota # - NetworkPolicy # disable_default_catalog_sources: # playbook default # - community-operators # pod_too_many_restarts: 100 # playbook default ...
-
Execute ansible playbook (no inventory required):
-
OpenShift cluster readiness verification:
ansible-navigator run openshift-readiness.yaml \ --extra-vars @settings.yaml \ --pull-policy missing \ --execution-environment true \ --execution-environment-image quay.io/bkhoo/ee-openshift-validation:1.0 \ --execution-environment-volume-mounts /home/bkhoo/.kube:/home/bkhoo/.kube:Z ### alternate method to run the playbook; this method requires all dependencies installed ansible-playbook openshift-readiness.yaml --extra-vars @settings.yaml
-
Application readiness:
ansible-navigator run application-readiness.yaml \ --extra-vars @settings.yaml \ --pull-policy missing \ --execution-environment true \ --execution-environment-image quay.io/bkhoo/ee-openshift-validation:1.0 \ --execution-environment-volume-mounts /home/bkhoo/.kube:/home/bkhoo/.kube:Z ### alternate method to run the playbook; this method requires all dependencies installed ansible-playbook application-readiness.yaml --extra-vars @settings.yaml
-
Cluster capacity estimation:
ansible-navigator run cluster-capacity.yaml \ --extra-vars @settings.yaml \ --pull-policy missing \ --execution-environment true \ --execution-environment-image quay.io/bkhoo/ee-openshift-validation:1.0 \ --execution-environment-volume-mounts /home/bkhoo/.kube:/home/bkhoo/.kube:Z ### alternate method to run the playbook; this method requires all dependencies installed ansible-playbook cluster-capacity.yaml --extra-vars @settings.yaml
-