Skip to content

Commit 9899112

Browse files
Merge pull request GoogleCloudPlatform#2349 from ostrain/ostrain-samples-cleanup
Minor cleanup to AppTeam and CloudSQL compositions samples
2 parents bd2ca7d + 0473ae6 commit 9899112

File tree

7 files changed

+57
-31
lines changed

7 files changed

+57
-31
lines changed

experiments/compositions/samples/AppTeam/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# AppTeam
1+
# AppTeam
22

3-
For now this would only work in CC from a specific project.
3+
For now this will only work in CC from a specific project.
44

55
## [Platform Admin] Create a Context object
66

7-
The first step is to create a context object in the namespace where AppTeam will be created.
7+
The first step is to create a context object in the namespace where AppTeam will
8+
be created.
89

910
```
1011
kubectl apply -f - <<EOF
@@ -24,7 +25,7 @@ EOF
2425
kubectl create -f composition/appteam.yaml
2526
```
2627

27-
## [Platform Admin] Create a new team `clearing`
28+
## [Platform Admin] Create a new team
2829

2930
Create a new `AppTeam` CR in the `config-control` namespace.
3031

@@ -61,7 +62,7 @@ When done with testing, cleanup the resources by deleting the `AppTeam` CRs.
6162
For now resources created in namespaces other than the `AppTeam` CR's namespace need to be manually cleaned up.
6263

6364
```
64-
kubectl delete appteam clearing
65+
kubectl delete appteam $TEAM_NAME
6566
6667
# to clean up objects not in the same namespace as facade
6768
./cleanup_appteam.sh ${TEAM_NAME}

experiments/compositions/samples/AppTeam/cleanup_appteam.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
1716
scriptpath=$(realpath $0)
1817
base=$(dirname $scriptpath)
1918

19+
if [[ $# != 1 ]];
20+
then
21+
echo "usage: ./cleanup_appteam.sh <project>"
22+
exit 1
23+
fi
24+
2025
project=$1
2126

2227
kubectl delete appteams.facade.facade -n config-control ${project}
@@ -33,4 +38,4 @@ echo "waiting for project to be deleted ......"
3338
sleep 30
3439

3540
kubectl delete configconnectorcontext.core.cnrm.cloud.google.com configconnectorcontext.core.cnrm.cloud.google.com -n ${project}
36-
kubectl delete namespace ${project}
41+
kubectl delete namespace ${project}

experiments/compositions/samples/AppTeam/get_appteam.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
scriptpath=$(realpath $0)
1818
base=$(dirname $scriptpath)
1919

20+
if [[ $# -lte 1 ]];
21+
then
22+
echo "usage: ./get_appteam.sh <project>"
23+
exit 1
24+
fi
25+
2026
project=$1
2127
opmodifier=$2
2228

@@ -41,4 +47,4 @@ kubectl get configconnectorcontext -n ${project} $opmodifier
4147
echo
4248
echo "Project ------------------------------------------"
4349
kubectl get project ${project} -n config-control $opmodifier
44-
echo
50+
echo

experiments/compositions/samples/CloudSQL/README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CloudSQL
1+
# CloudSQL
22

33
## [Platform Admin] Create the composition
44

@@ -8,13 +8,14 @@ kubectl create -f composition/hasql.yaml
88

99
## [Team Admin] Create CloudSQL instance
1010

11-
Please note we are creating this in `config-control` namespace for the sample.
12-
If KCC is setup in a tenant namespace (say using `AppTeams` composition), then we can use the tenant namespace instead.
11+
Please note we are creating this in `config-control` namespace for this sample.
12+
If KCC is setup in a tenant namespace (say using the `AppTeam` sample
13+
composition), then we can use the tenant namespace instead.
1314

1415
```
1516
NAMESPACE=config-control
1617
#NAMESPACE=<app-team's namespace>
17-
18+
1819
kubectl apply -f - <<EOF
1920
apiVersion: facade.compositions.google.com/v1
2021
kind: CloudSQL
@@ -29,16 +30,16 @@ spec:
2930
EOF
3031
```
3132

32-
Verify the relevant resources are created succesfully
33+
Verify the relevant resources are created succesfully by running:
3334

3435
```
3536
./get_cloudsql.sh ${NAMESPACE}
3637
```
3738

3839
## [Team Admin] Cleaning up
3940

40-
When done with testing, cleanup the resources by deleting the `CloudSQL` CRs.
41+
When done with testing, clean up the resources by deleting the `CloudSQL` CRs:
4142

4243
```
4344
kubectl delete cloudsql myteam -n ${NAMESPACE}
44-
```
45+
```

experiments/compositions/samples/CloudSQL/cleanup_cloudsql.sh

+15-10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
scriptpath=$(realpath $0)
1818
base=$(dirname $scriptpath)
1919

20+
if [[ $# -ne 2 ]];
21+
then
22+
echo "usage: ./cleanup_cloudsql.sh <name> <namespace>"
23+
exit 1
24+
fi
2025

2126
name=$1
2227
namespace=$2
@@ -25,14 +30,14 @@ kubectl delete -f cloudsqls.facade.facade -n $namespace ${name}
2530

2631
kubectl delete sqlinstances.sql.cnrm.cloud.google.com -n $namespace ${name}-db-main
2732
kubectl delete sqlinstances.sql.cnrm.cloud.google.com -n $namespace ${name}-db-replica-us-central1
28-
kubectl delete kmskeyring -n $namespace kmscryptokeyring-us-central1
29-
kubectl delete kmskeyring -n $namespace kmscryptokeyring-us-east1
30-
kubectl delete kmscryptokey -n $namespace kmscryptokey-enc-us-central1
31-
kubectl delete kmscryptokey -n $namespace kmscryptokey-enc-us-east1
32-
kubectl delete iampolicymember -n $namespace sql-kms-us-east1-policybinding
33-
kubectl delete iampolicymember -n $namespace sql-kms-us-central1-policybinding
34-
kubectl delete serviceidentity -n $namespace sqladmin.googleapis.com
35-
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace cloudkms.googleapis.com
36-
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace iam.googleapis.com
33+
kubectl delete kmskeyring -n $namespace kmscryptokeyring-us-central1
34+
kubectl delete kmskeyring -n $namespace kmscryptokeyring-us-east1
35+
kubectl delete kmscryptokey -n $namespace kmscryptokey-enc-us-central1
36+
kubectl delete kmscryptokey -n $namespace kmscryptokey-enc-us-east1
37+
kubectl delete iampolicymember -n $namespace sql-kms-us-east1-policybinding
38+
kubectl delete iampolicymember -n $namespace sql-kms-us-central1-policybinding
39+
kubectl delete serviceidentity -n $namespace sqladmin.googleapis.com
40+
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace cloudkms.googleapis.com
41+
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace iam.googleapis.com
3742
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace serviceusage.googleapis.com
38-
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace sqladmin.googleapis.com
43+
kubectl delete services.serviceusage.cnrm.cloud.google.com -n $namespace sqladmin.googleapis.com

experiments/compositions/samples/CloudSQL/get_cloudsql.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
scriptpath=$(realpath $0)
1818
base=$(dirname $scriptpath)
1919

20+
if [[ $# -ne 1 ]];
21+
then
22+
echo "usage: ./get_cloudsql.sh <namespace>"
23+
exit 1
24+
fi
25+
2026
namespace=$1
2127

2228
echo "ServiceIdentity ----------------------------------------"
@@ -35,4 +41,4 @@ echo "IAMPolicyMember ----------------------------------------"
3541
kubectl get iampolicymember -n $namespace
3642
echo
3743
echo "ServiceUsage -------------------------------------------"
38-
kubectl get services.serviceusage.cnrm.cloud.google.com -n $namespace
44+
kubectl get services.serviceusage.cnrm.cloud.google.com -n $namespace

experiments/compositions/samples/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Using Samples
1+
# Using Samples
22

33
## Prerequisites
44

5-
A Config Controller cluster with Composition installed.
5+
A Config Controller cluster with Compositions installed.
66

77
## Personas/Roles
88

@@ -17,9 +17,11 @@ Team/App Owner/Admin:
1717

1818
## AppTeam: Setting up New Teams
1919

20-
This recipe creates a GCP project for the team as well as sets up KCC in namespace mode to manage the team project.
20+
This recipe creates a GCP project for the team as well as sets up KCC in
21+
namespace mode to manage the team project.
2122

2223
## SQLHA: Create CloudSQL in HA Mode
2324

24-
Use AppTeam recipe to create a team first.
25-
Then use this recipe to setup CloudSQL in your project in HA mode.
25+
This recipe sets up a CloudSQL instance in your project in HA mode. If you'd
26+
like to create the instance in a tenant namespace, do the AppTeam sample first
27+
to create one.

0 commit comments

Comments
 (0)