-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: manuel service account generator (#210)
* chore: test passing name into login action * chore: modifiy deploy login process * chore: modify service account reference * chore: complete the manually run script for sa creation * chore: update the login credential use in all actions * chore: remove testing stanza from deploy staggered * chore: fix test workflow old * chore: fix xlog compare job * chore: change xlog credential to production
- Loading branch information
1 parent
449d73b
commit 89b90cf
Showing
15 changed files
with
590 additions
and
24 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
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
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
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 @@ | ||
# Generating service accounts for the CICD pipeline | ||
|
||
The github actions need service accounts to run. The script `generate_sa.sh` will create a service acount for the prod environment of a given openshift project and give that account the roles in the dev, test, and prod environments for deploying the keycloak site. | ||
|
||
## Generate the service accounts | ||
|
||
While logged into the **Gold** instance run: | ||
|
||
` | ||
./generate_sa.sh <<LICENCE_PLATE>> gold | ||
` | ||
|
||
The service account, roles, and rolebindings will be created. | ||
|
||
Log into the **GoldDR** cluster and repeat the same command. | ||
|
||
` | ||
./generate_sa.sh <<LICENCE_PLATE>> golddr | ||
` | ||
|
||
## Update the github action secrets | ||
|
||
The github actions rwquire 4 secrets to deploy resources in Gold and GoldDR. | ||
|
||
Each service account will generate a secret in the `-prod` namespace with the name `sso-action-deployer-<<LICENCE_PLATE>>-token-#####`. Copy this token into the GithHub secrets on this repos. | ||
|
||
OPENSHIFT_TOKEN_GOLD_SANDBOX | ||
OPENSHIFT_TOKEN_GOLDDR_SANDBOX | ||
OPENSHIFT_TOKEN_GOLD_PRODUCTION | ||
OPENSHIFT_TOKEN_GOLDDR_PRODUCTION |
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,57 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
usage() { | ||
cat <<EOF | ||
Creates a service account for the dev test and prod environments of the project with | ||
namespace licence plate arg. | ||
Usages: | ||
$0 <project_licence_plate> <cluster> | ||
Available licence plates: | ||
- e4ca1d | ||
- eb75ad | ||
Available Clusters | ||
- gold | ||
- golddr | ||
Examples: | ||
$ $0 e4ca1d gold | ||
EOF | ||
} | ||
|
||
if [ "$#" -lt 2 ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
licence_plate=$1 | ||
cluster=$2 | ||
|
||
# create service account in prod | ||
oc -n "$licence_plate"-prod create sa sso-action-deployer-"$licence_plate" | ||
|
||
|
||
|
||
create_role_and_binding() { | ||
if [ "$#" -lt 3 ]; then exit 1; fi | ||
licence_plate=$1 | ||
env=$2 | ||
cluster=$3 | ||
namespace="$licence_plate-$env" | ||
|
||
oc process -f ./templates/role-"$cluster".yaml -p NAMESPACE="$namespace" | oc -n "$namespace" apply -f - | ||
|
||
oc -n "$namespace" create rolebinding sso-action-deployer-role-binding-"$namespace" \ | ||
--role=sso-action-deployer-"$namespace" \ | ||
--serviceaccount="$licence_plate"-prod:sso-action-deployer-"$licence_plate" | ||
} | ||
|
||
# for dev, test and prod create the role and role binding | ||
create_role_and_binding "$licence_plate" "prod" "$cluster" | ||
|
||
create_role_and_binding "$licence_plate" "test" "$cluster" | ||
|
||
create_role_and_binding "$licence_plate" "dev" "$cluster" |
Oops, something went wrong.