forked from open-cluster-management-io/policy-collection
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add policy to setup download of PolicyGenerator from hub
Signed-off-by: Brian Jarvis <[email protected]> (cherry picked from commit 60035db)
- Loading branch information
1 parent
967fdec
commit 018c29b
Showing
8 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
policygenerator/policy-sets/community/policygenerator-download/consoleclidownload.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
apiVersion: console.openshift.io/v1 | ||
kind: ConsoleCLIDownload | ||
metadata: | ||
name: policygenerator | ||
spec: | ||
description: The Policy Generator is a part of the Red Hat Advanced Cluster Management for Kubernetes application lifecycle subscription GitOps workflow that generates Red Hat Advanced Cluster Management policies using Kustomize. The Policy Generator builds Red Hat Advanced Cluster Management policies from Kubernetes manifest YAML files, which are provided through a PolicyGenerator manifest YAML file that is used to configure it. The Policy Generator is implemented as a Kustomize generator plug-in. | ||
displayName: 'Advanced Cluster Management - v{{ (lookup "operator.open-cluster-management.io/v1" "MultiClusterHub" "open-cluster-management" "multiclusterhub").status.currentVersion }}' | ||
links: | ||
- href: 'https://policygen-downloader.{{ (lookup "config.openshift.io/v1" "Ingress" "" "cluster").spec.domain }}/PolicyGenerator' | ||
text: Download PolicyGenerator for Linux for x86_64 |
91 changes: 91 additions & 0 deletions
91
policygenerator/policy-sets/community/policygenerator-download/deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: policygen-downloader | ||
spec: | ||
remediationAction: enforce | ||
severity: low | ||
object-templates-raw: | | ||
{{- $ocmDeployment := (lookup "apps/v1" "Deployment" "open-cluster-management" "multicluster-operators-hub-subscription") }} | ||
{{- $ocmContainer := "" }} | ||
{{- range $cn := $ocmDeployment.spec.template.spec.containers }} | ||
{{- if eq $cn.name "multicluster-operators-hub-subscription" }} | ||
{{- $ocmContainer = $cn }} | ||
{{- break }} | ||
{{- end }} | ||
{{- end }} | ||
- complianceType: musthave | ||
objectDefinition: | ||
kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: policygen-downloader | ||
namespace: open-cluster-management-downloader | ||
labels: | ||
app: policygen-downloader | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: policygen-downloader | ||
template: | ||
metadata: | ||
labels: | ||
app: policygen-downloader | ||
deployment: policygen-downloader | ||
spec: | ||
{{- if not (empty $ocmDeployment.spec.template.spec.nodeSelector) }} | ||
nodeSelector: | ||
{{- range $k, $v := $ocmDeployment.spec.template.spec.nodeSelector }} | ||
{{ $k }}: {{ (empty $v) | ternary "''" $v }} | ||
{{- end }} | ||
{{- end }} | ||
initContainers: | ||
- args: | ||
- -c | ||
- cp /etc/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator | ||
/policy-generator/PolicyGenerator | ||
command: | ||
- /bin/bash | ||
image: {{ $ocmContainer.image }} | ||
name: policy-generator-install | ||
volumeMounts: | ||
- mountPath: /policy-generator | ||
name: policy-generator | ||
containers: | ||
- name: policygen-downloader | ||
image: registry.access.redhat.com/ubi8/httpd-24:latest | ||
ports: | ||
- containerPort: 8080 | ||
protocol: TCP | ||
resources: {} | ||
imagePullPolicy: Always | ||
volumeMounts: | ||
- mountPath: /var/www/html/ | ||
name: policy-generator | ||
{{- if not (empty $ocmDeployment.spec.template.spec.tolerations) }} | ||
tolerations: | ||
{{- range $tol := $ocmDeployment.spec.template.spec.tolerations }} | ||
- key: {{ $tol.key }} | ||
operator: {{ $tol.operator }} | ||
{{- if not (empty $tol.effect) }} | ||
effect: {{ $tol.effect }} | ||
{{- end }} | ||
{{- if not (empty $tol.value) }} | ||
value: {{ $tol.val }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
volumes: | ||
- emptyDir: {} | ||
name: policy-generator | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxUnavailable: 25% | ||
maxSurge: 25% | ||
revisionHistoryLimit: 10 |
30 changes: 30 additions & 0 deletions
30
policygenerator/policy-sets/community/policygenerator-download/generator.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: PolicyGenerator | ||
metadata: | ||
name: policygenerator-download | ||
policyDefaults: | ||
namespace: policies | ||
remediationAction: inform ## Change to enforce to create the downloader objects on the cluster | ||
## set the default compliance annotations | ||
categories: | ||
- CM Configuration Management | ||
controls: | ||
- CM-2 Baseline Configuration | ||
standards: | ||
- NIST SP 800-53 | ||
severity: low | ||
placement: | ||
labelSelector: | ||
matchLabels: | ||
name: local-cluster | ||
|
||
policies: | ||
- name: acm-policygenerator-downloader | ||
manifests: | ||
- path: namespace.yml | ||
- path: deployment.yml | ||
- path: service.yml | ||
- path: route.yml | ||
- path: consoleclidownload.yml | ||
complianceType: mustonlyhave |
6 changes: 6 additions & 0 deletions
6
policygenerator/policy-sets/community/policygenerator-download/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
|
||
generators: | ||
- generator.yml |
5 changes: 5 additions & 0 deletions
5
policygenerator/policy-sets/community/policygenerator-download/namespace.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
kind: Namespace | ||
apiVersion: v1 | ||
metadata: | ||
name: open-cluster-management-downloader |
20 changes: 20 additions & 0 deletions
20
policygenerator/policy-sets/community/policygenerator-download/route.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
kind: Route | ||
apiVersion: route.openshift.io/v1 | ||
metadata: | ||
name: policygen-downloader | ||
namespace: open-cluster-management-downloader | ||
labels: | ||
app: policygen-downloader | ||
spec: | ||
host: 'policygen-downloader.{{ (lookup "config.openshift.io/v1" "Ingress" "" "cluster").spec.domain }}' | ||
to: | ||
kind: Service | ||
name: policygen-downloader | ||
weight: 100 | ||
port: | ||
targetPort: 8080-tcp | ||
tls: | ||
termination: edge | ||
insecureEdgeTerminationPolicy: Redirect | ||
wildcardPolicy: None |
21 changes: 21 additions & 0 deletions
21
policygenerator/policy-sets/community/policygenerator-download/service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: policygen-downloader | ||
namespace: open-cluster-management-downloader | ||
labels: | ||
app: policygen-downloader | ||
spec: | ||
ipFamilies: | ||
- IPv4 | ||
ports: | ||
- name: 8080-tcp | ||
protocol: TCP | ||
port: 8080 | ||
targetPort: 8080 | ||
internalTrafficPolicy: Cluster | ||
type: ClusterIP | ||
sessionAffinity: None | ||
selector: | ||
app: policygen-downloader |