-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from appuio/initial
Add initial version of component
- Loading branch information
Showing
22 changed files
with
443 additions
and
5 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
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 |
---|---|---|
|
@@ -22,3 +22,4 @@ _archive/ | |
_public/ | ||
|
||
# Additional entries | ||
jsonnetfile.json |
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
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
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
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,65 @@ | ||
local com = import 'lib/commodore.libjsonnet'; | ||
local kap = import 'lib/kapitan.libjsonnet'; | ||
local kube = import 'lib/kube.libjsonnet'; | ||
local inv = kap.inventory(); | ||
// The hiera parameters for the component | ||
local params = inv.parameters.group_sync_operator; | ||
|
||
local labels = { | ||
'app.kubernetes.io/managed-by': 'commodore', | ||
'app.kubernetes.io/part-of': 'syn', | ||
'app.kubernetes.io/name': 'group-sync-operator', | ||
}; | ||
|
||
// | ||
local addCredentialNamespace(config, provider) = | ||
if std.objectHas(config[provider], 'credentialsSecret') then | ||
config { | ||
[provider]+: { | ||
credentialsSecret+: { | ||
namespace: params.namespace, | ||
}, | ||
}, | ||
} | ||
else | ||
config; | ||
|
||
local patchProvider(p) = std.foldl(addCredentialNamespace, std.objectFields(p), com.makeMergeable(p)); | ||
|
||
local groupSyncs = [ | ||
if !std.objectHas(params.sync[k], 'providers') then | ||
error 'GroupSync needs to have at least one provider' | ||
else | ||
{ | ||
apiVersion: 'redhatcop.redhat.io/v1alpha1', | ||
kind: 'GroupSync', | ||
metadata: { | ||
name: k, | ||
namespace: params.namespace, | ||
labels+: labels, | ||
}, | ||
spec: { | ||
providers: [ | ||
{ name: p } + patchProvider(params.sync[k].providers[p]) | ||
for p in std.objectFields(params.sync[k].providers) | ||
], | ||
}, | ||
} | ||
for k in std.objectFields(params.sync) | ||
]; | ||
|
||
local credentials = [ | ||
kube.Secret(s) { | ||
type: 'Opaque', | ||
metadata+: { | ||
namespace: params.namespace, | ||
labels+: labels, | ||
}, | ||
} + com.makeMergeable(params.secrets[s]) | ||
for s in std.objectFields(params.secrets) | ||
]; | ||
|
||
{ | ||
[if std.length(groupSyncs) > 0 then '02_groupsync']: groupSyncs, | ||
[if std.length(credentials) > 0 then '02_credentials']: credentials, | ||
} |
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
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,43 @@ | ||
// main template for group-sync-operator | ||
local kap = import 'lib/kapitan.libjsonnet'; | ||
local kube = import 'lib/kube.libjsonnet'; | ||
local inv = kap.inventory(); | ||
// The hiera parameters for the component | ||
local params = inv.parameters.group_sync_operator; | ||
|
||
local operatorgroup = { | ||
apiVersion: 'operators.coreos.com/v1', | ||
kind: 'OperatorGroup', | ||
metadata: { | ||
name: 'group-sync-operator', | ||
}, | ||
spec: { | ||
targetNamespaces: [ | ||
params.namespace, | ||
], | ||
}, | ||
}; | ||
|
||
local subscription = { | ||
apiVersion: 'operators.coreos.com/v1alpha1', | ||
kind: 'Subscription', | ||
metadata: { | ||
name: 'group-sync-operator', | ||
}, | ||
spec: params.subscription, | ||
}; | ||
|
||
local operator = [ | ||
operatorgroup, | ||
subscription, | ||
]; | ||
|
||
// Define outputs below | ||
{ | ||
['01_' + std.asciiLower(obj.kind)]: obj { | ||
metadata+: { | ||
namespace: params.namespace, | ||
}, | ||
} | ||
for obj in operator | ||
} |
46 changes: 46 additions & 0 deletions
46
docs/modules/ROOT/pages/how-tos/configure-keycloak-sync.adoc
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,46 @@ | ||
= Configure Group Sync with Keycloak | ||
|
||
To synchronize groups with Keycloak a user with permissions to query for Keycloak groups must be available. | ||
The following permissions must be associated to the user: | ||
|
||
* Password must be set (Temporary option unselected) on the Credentials tab | ||
* On the Role Mappings tab, select master-realm or realm-management next to the Client Roles dropdown and then select query-groups, query-users, and view-users. | ||
You should then store the username and password in Vault. | ||
|
||
[source,shell] | ||
---- | ||
vault kv put -cas=0 clusters/kv/${TENANT_ID}/${CLUSTER_ID}/group-sync-operator/foo/keycloak username=$USERNAME password=$PASSWORD | ||
---- | ||
|
||
The following is an example of a configuration that will synchronize all groups in realm `foo-public`. | ||
It assumes that the username and password is accessible in Vault at the provided location. | ||
|
||
[source,yaml] | ||
---- | ||
parameters: | ||
group_sync_operator: | ||
sync: | ||
foo: | ||
schedule: '* * * * *' | ||
providers: | ||
keycloak: | ||
keycloak: | ||
url: https://id.company.io | ||
credentialsSecret: | ||
name: foo-keycloak | ||
loginRealm: master <1> | ||
realm: foo-public | ||
scope: sub <2> | ||
secrets: | ||
foo-keycloak: | ||
stingData: | ||
username: '?{vaultkv:${cluster:tenant}/${cluster:name}/group-sync-operator/foo/keycloak/username}' | ||
password: '?{vaultkv:${cluster:tenant}/${cluster:name}/group-sync-operator/foo/keycloak/password}' | ||
---- | ||
<1> The `loginRealm` is the realm where the API user is defined. | ||
<2> Scope for group synchronization. | ||
`sub` will also synchronize subgroups while `one` won't. | ||
|
||
NOTE: It's recommended to have the sync user in a separate realm. |
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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
* xref:index.adoc[Home] | ||
* xref:references/parameters.adoc[Parameters] | ||
* xref:how-tos/configure-keycloak-sync.adoc[Configure Group Sync with Keycloak] | ||
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 |
---|---|---|
@@ -1,3 +1,41 @@ | ||
# Overwrite parameters here | ||
parameters: | ||
group_sync_operator: | ||
sync: | ||
foo: | ||
schedule: '* * * * *' | ||
providers: | ||
keycloak: | ||
keycloak: | ||
url: https://id.company.io | ||
credentialsSecret: | ||
name: foo-keycloak | ||
loginRealm: foo-public | ||
realm: foo-public | ||
scope: sub | ||
newProvider: | ||
credentialsSecret: | ||
name: foo-keycloak | ||
credless: | ||
keycloak: | ||
url: https://id.company.io | ||
loginRealm: bar-public | ||
realm: bar-public | ||
scope: sub | ||
other: | ||
schedule: '* * 2 * *' | ||
providers: | ||
foo: | ||
azure: | ||
credentialsSecret: | ||
name: other-foo | ||
|
||
# parameters: {...} | ||
secrets: | ||
foo-keycloak: | ||
stingData: | ||
username: foo | ||
password: bar | ||
other-foo: | ||
stingData: | ||
AZURE_TENANT_ID: 1a | ||
AZURE_CLIENT_ID: foobar | ||
AZURE_CLIENT_SECRET: secret |
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,2 @@ | ||
parameters: | ||
group_sync_operator: {} |
7 changes: 7 additions & 0 deletions
7
tests/golden/defaults/group-sync-operator/group-sync-operator/00_namespace.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,7 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
annotations: {} | ||
labels: | ||
name: syn-group-sync-operator | ||
name: syn-group-sync-operator |
8 changes: 8 additions & 0 deletions
8
tests/golden/defaults/group-sync-operator/group-sync-operator/01_operatorgroup.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,8 @@ | ||
apiVersion: operators.coreos.com/v1 | ||
kind: OperatorGroup | ||
metadata: | ||
name: group-sync-operator | ||
namespace: syn-group-sync-operator | ||
spec: | ||
targetNamespaces: | ||
- syn-group-sync-operator |
11 changes: 11 additions & 0 deletions
11
tests/golden/defaults/group-sync-operator/group-sync-operator/01_subscription.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,11 @@ | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: Subscription | ||
metadata: | ||
name: group-sync-operator | ||
namespace: syn-group-sync-operator | ||
spec: | ||
channel: alpha | ||
installPlanApproval: Automatic | ||
name: group-sync-operator | ||
source: community-operators | ||
sourceNamespace: openshift-marketplace |
Oops, something went wrong.