Synchronize Cluster Configuration using OpenShift Hive — SyncSets and SelectorSyncSets

apiVersion: hive.openshift.io/v1
kind: SyncSet
metadata:
name: example-syncset
namespace: okd
spec:
clusterDeploymentRefs:
- name: okd
resources:
- apiVersion: v1
kind: Namespace
metadata:
name: myproject
patches:
- kind: Config
apiVersion: imageregistry.operator.openshift.io/v1
name: cluster
applyMode: AlwaysApply
patch: |-
{ "spec": { "defaultRoute": true }}
patchType: merge
secretReferences:
- source:
name: mysecret
namespace: okd
target:
name: mysecret
namespace: myproject
---
apiVersion: hive.openshift.io/v1
kind: SelectorSyncSet
metadata:
name: mygroup
spec:
resources:
- apiVersion: v1
kind: Namespace
metadata:
name: myproject
resourceApplyMode: Sync
clusterDeploymentSelector:
matchLabels:
cluster-group: okd
$ wget -O syncset-gen https://github.com/matt-simons/syncset-gen/releases/download/v0.5/syncset-gen_linux_amd64 && chmod +x ./syncset-gen
$ sudo mv ./syncset-gen /usr/bin/
$ syncset-gen view -h
Parses a manifest directory and prints a SyncSet/SelectorSyncSet representation of the objects it contains.

Usage:
ss view [flags]

Flags:
-c, --cluster-name string The cluster name used to match the SyncSet to a Cluster
-h, --help help for view
-p, --patches string The directory of patch manifest files to use
-r, --resources string The directory of resource manifest files to use
-s, --selector string The selector key/value pair used to match the SelectorSyncSet to Cluster(s)
$ tree
.
└── config
├── patch
│ └── cluster-version.yaml
└── resource
└── namespace.yaml
$ syncset-gen view okd-cluster-group-selectorsyncset --selector cluster-group/okd -p ./config/patch/ -r ./config/resource/
{
"kind": "SelectorSyncSet",
"apiVersion": "hive.openshift.io/v1",
"metadata": {
"name": "okd-cluster-group-selectorsyncset",
"creationTimestamp": null,
"labels": {
"generated": "true"
}
},
"spec": {
"resources": [
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"name": "myproject"
}
}
],
"resourceApplyMode": "Sync",
"patches": [
{
"apiVersion": "config.openshift.io/v1",
"kind": "ClusterVersion",
"name": "version",
"patch": "{\"spec\": {\"channel\": \"stable-4.3\",\"desiredUpdate\": {\"version\": \"4.3.0\", \"image\": \"quay.io/openshift-release-dev/ocp-release@sha256:3a516480dfd68e0f87f702b4d7bdd6f6a0acfdac5cd2e9767b838ceede34d70d\"}}}",
"patchType": "merge"
},
{
"apiVersion": "rbac.authorization.k8s.io/v1",
"kind": "ClusterRoleBinding",
"name": "self-provisioners",
"patch": "{\"subjects\": null}",
"patchType": "merge"
}
],
"clusterDeploymentSelector": {
"matchExpressions": [
{
"key": "cluster-group/okd",
"operator": "Exists"
}
]
}
},
"status": {}
}
$ oc get syncsetinstance -n <namespace>
$ oc get syncsetinstances <synsetinstance name> -o yaml

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store