Skip to content

Commit 3719313

Browse files
committed
Infra
1 parent 899ff73 commit 3719313

File tree

6 files changed

+128
-20
lines changed

6 files changed

+128
-20
lines changed

.github/workflows/delete-cluster.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313
with:
1414
persist-credentials: false
1515
fetch-depth: 0
16-
- name: Create cluster
16+
- name: Delete cluster
1717
run: |
18-
rm infra/${NAME}-cluster.yaml
18+
rm infra/${{ inputs.name }}.yaml
1919
- name: Commit changes
2020
run: |
2121
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
2222
git config --local user.name "github-actions[bot]"
2323
git add .
24-
git commit -m "Create cluster ${{ inputs.name }}"
24+
git commit -m "Delete cluster ${{ inputs.name }}"
2525
- name: Push changes
2626
uses: ad-m/github-push-action@master
2727
with:

argocd/port.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,31 @@ spec:
3333
- identifier: '"dot"'
3434
title: '"dot"'
3535
blueprint: '"cluster"'
36+
properties:
37+
provider: '"n/a"'
38+
- kind: devopstoolkitseries.com/v1alpha1/clusterclaims
39+
port:
40+
entity:
41+
mappings:
42+
- identifier: .metadata.name + "-" + "cluster"
43+
title: .metadata.name + "-" + "cluster"
44+
blueprint: '"cluster"'
45+
properties:
46+
provider: .spec.compositionSelector.matchLabels.provider
47+
node-size: .spec.parameters.nodeSize
48+
min-node-count: .spec.parameters.minNodeCount
49+
status: .status.controlPlaneStatus
50+
- kind: v1/secrets
51+
selector:
52+
query: .type == "connection.crossplane.io/v1alpha1"
53+
port:
54+
entity:
55+
mappings:
56+
- identifier: .metadata.name
57+
title: .metadata.name
58+
blueprint: '"cluster"'
59+
properties:
60+
kube-config: .data.kubeconfig
3661
- kind: v1/namespaces
3762
selector:
3863
query: .metadata.annotations.environment == "true"

port/backend-app-action.json

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
[
21
{
32
"identifier": "create-backend-db",
43
"title": "Create Backend App With DB",
@@ -74,4 +73,3 @@
7473
"trigger": "CREATE",
7574
"description": "Create a new backend application with a DB."
7675
}
77-
]

port/cluster-blueprint.json

+14-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"provider": {
99
"type": "string",
1010
"title": "Provider",
11-
"default": "civo",
11+
"default": "n/a",
1212
"description": "The provider where the cluster is hosted",
1313
"enum": [
14-
"civo"
14+
"civo",
15+
"n/a"
1516
]
1617
},
1718
"node-size": {
@@ -30,6 +31,16 @@
3031
"title": "Minimum number of nodes",
3132
"default": 1,
3233
"description": "The minimun number of nodes (autoscaler might increase this number)"
34+
},
35+
"kube-config": {
36+
"type": "string",
37+
"title": "Kube config",
38+
"description": "Kube config"
39+
},
40+
"status": {
41+
"type": "string",
42+
"title": "Status",
43+
"description": "The status of the cluster"
3344
}
3445
},
3546
"required": [
@@ -43,7 +54,7 @@
4354
"cluster": {
4455
"type": "string",
4556
"title": "Cluster",
46-
"calculation": "if .properties.provider == \"civo\" then \"ck-all\" end"
57+
"calculation": "if .properties.provider == \"civo\" then \"ck-port\" end"
4758
}
4859
},
4960
"relations": {}

port/cluster-delete-action.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
"name": {
77
"type": "string",
88
"title": "Name",
9-
"description": "The name of the cluster"
9+
"description": "Confirm by typing the name of the cluster"
1010
}
1111
},
1212
"required": [
13-
"name",
13+
"name"
1414
]
1515
},
1616
"invocationMethod": {
1717
"type": "GITHUB",
1818
"org": "vfarcic",
1919
"repo": "idp-demo",
20-
"workflow": "create-cluster.yaml",
20+
"workflow": "delete-cluster.yaml",
2121
"omitPayload": true
2222
},
2323
"trigger": "DELETE",

setup-infra.sh

+83-9
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ Feel free to say "No" and inspect the script if you prefer setting up resources
1919

2020
echo "
2121
## You will need following tools installed:
22-
|Name |Required |More info |
23-
|----------------|---------------------|---------------------------------------------------|
24-
|Charm Gum |Yes |'https://github.com/charmbracelet/gum#installation'|
25-
|kubectl |Yes |'https://kubernetes.io/docs/tasks/tools/#kubectl' |
26-
|helm |Yes |'https://helm.sh/docs/intro/install/' |
27-
|jq |Yes |'https://stedolan.github.io/jq/download' |
28-
|yq |Yes |'https://github.com/mikefarah/yq#install' |
22+
|Name |More info |
23+
|----------------|---------------------------------------------------|
24+
|Charm Gum |'https://github.com/charmbracelet/gum#installation'|
25+
|kubectl |'https://kubernetes.io/docs/tasks/tools/#kubectl' |
26+
|helm |'https://helm.sh/docs/intro/install/' |
27+
|jq |'https://stedolan.github.io/jq/download' |
28+
|yq |'https://github.com/mikefarah/yq#install' |
29+
|Python |'https://www.python.org/downloads' |
2930
" | gum format
3031

3132
gum confirm "
@@ -72,10 +73,44 @@ kubectl apply --filename argocd/project.yaml
7273

7374
yq --inplace ".spec.source.repoURL = \"https://github.com/$GITHUB_ORG/idp-demo\"" argocd/apps.yaml
7475

75-
yq --inplace ".spec.source.repoURL = \"https://github.com/${GITHUB_ORG}/idp-demo.git\"" argocd/cluster-template.yaml
76-
7776
kubectl apply --filename argocd/apps.yaml
7877

78+
##################################
79+
# Schema Management (SchemaHero) #
80+
##################################
81+
82+
cp argocd/schema-hero.yaml infra/.
83+
84+
git add .
85+
86+
git commit -m "Add SchemaHero"
87+
88+
git push
89+
90+
gum spin --spinner line --title "Waiting for SchemaHero to synchronize..." -- sleep 180
91+
92+
#########################################
93+
# Secrets Management (External Secrets) #
94+
#########################################
95+
96+
cp argocd/external-secrets.yaml infra/.
97+
98+
git add .
99+
100+
git commit -m "External Secrets"
101+
102+
git push
103+
104+
gum spin --spinner line --title "Waiting for External Secrets to synchronize..." -- sleep 180
105+
106+
cp eso/secret-store-$HYPERSCALER.yaml infra/.
107+
108+
git add .
109+
110+
git commit -m "External Secrets Store"
111+
112+
git push
113+
79114
########
80115
# Port #
81116
########
@@ -92,6 +127,45 @@ cat port/cluster-delete-action.json \
92127

93128
mv port/cluster-delete-action.json.tmp port/cluster-delete-action.json
94129

130+
python -m pip install requests
131+
132+
echo '
133+
Execute `cat port/environment-blueprint.json`, copy the output,
134+
and use it to create a new blueprint in https://app.getport.io.'
135+
136+
gum input --placeholder "
137+
Press the enter key to continue."
138+
139+
echo '
140+
Execute `cat port/backend-app-blueprint.json`, copy the output,
141+
and use it to create a new blueprint in https://app.getport.io.'
142+
143+
gum input --placeholder "
144+
Press the enter key to continue."
145+
146+
PORT_CLIENT_ID=$(gum input --placeholder "Please enter Port client ID." --password)
147+
148+
PORT_CLIENT_SECRET=$(gum input --placeholder "Please enter Port client secret." --password)
149+
150+
cat argocd/port.yaml \
151+
| sed -e "s@CLIENT_ID@$PORT_CLIENT_ID@g" \
152+
| sed -e "s@CLIENT_SECRET@$PORT_CLIENT_SECRET@g" \
153+
| tee infra/port.yaml
154+
155+
git add .
156+
157+
git commit -m "Port"
158+
159+
git push
160+
161+
echo '
162+
Execute `cat port/backend-app-action.json`, copy the output,
163+
and use it to create a action inside the `Backend App`
164+
blueprint in https://app.getport.io.'
165+
166+
gum input --placeholder "
167+
Press the enter key to continue."
168+
95169
########
96170
# Repo #
97171
########

0 commit comments

Comments
 (0)