2.6.4.2.3. fromClusterClaim function
fromClusterClaim
功能返回 ClusterClaim
资源中的 Spec.Value
的值。查看该功能的以下语法:
func fromClusterClaim (clusterclaimName string) (value map[string]interface{}, err Error)
当使用功能时,输入 Kubernetes ClusterClaim
资源的名称。如果 ClusterClaim
资源不存在,您会收到策略违反情况。查看在目标受管集群上强制执行 Kubernetes 资源的配置策略示例。platform
数据键的值是一个模板,它检索 platform.open-cluster-management.io
集群声明的值。同样,它从 ClusterClaim
获取产品
和版本
的值:
apiVersion: policy.open-cluster-management.io/v1 kind: ConfigurationPolicy metadata: name: demo-clusterclaims namespace: default spec: namespaceSelector: exclude: - kube-* include: - default object-templates: - complianceType: musthave objectDefinition: kind: ConfigMap apiVersion: v1 metadata: name: sample-app-config namespace: default data: # Configuration values can be set as key-value properties platform: '{{ fromClusterClaim "platform.open-cluster-management.io" }}' product: '{{ fromClusterClaim "product.open-cluster-management.io" }}' version: '{{ fromClusterClaim "version.openshift.io" }}' remediationAction: enforce severity: low