Skip to content

Commit d490ddb

Browse files
bartrchaosdinosaurkev-ms
authored
new lab - registering Namespace and Applications (#84)
* updated byoa lab * updated build * updated GitOps * updated labs * removed old ci-cd * updated ds groups list * removed unused files * patch for http bug --------- Co-authored-by: ehoops-microsoft <[email protected]> Co-authored-by: Kevin Shah <[email protected]>
1 parent 7f57a9e commit d490ddb

File tree

158 files changed

+451
-25565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+451
-25565
lines changed

.devcontainer/deploy-res-edge.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# Warning: this is a destructive command
4+
5+
# This script will create a new cluster and deploy Res-Edge Data Service
6+
# Any prior data service changes will be overwritten and are not recoverable
7+
# Use the --force flag to make the database changes
8+
9+
# a little protection
10+
if [ "$1" != "--force" ]; then
11+
echo ""
12+
echo "This is a destructive command that deletes your current cluster"
13+
econ "and creates a new cluster with Res-Edge Data Service deployed"
14+
echo ""
15+
echo "Usage: .devcontainer/deploy-res-edge.sh --force"
16+
echo ""
17+
exit 1
18+
fi
19+
20+
set -e
21+
22+
cd "$KIC_BASE/deploy" || exit 1
23+
24+
# delete and create a new cluster
25+
kic cluster create
26+
27+
# create the namespace
28+
kubectl apply -f ns.yaml
29+
30+
# deploy SQL Server with sample data
31+
kubectl apply -k mssql
32+
33+
# deploy monitoring and logging
34+
kubectl apply -k monitoring
35+
36+
echo
37+
echo 'waiting for mssql pod to start'
38+
kubectl wait pod --all --for condition=ready -n api --timeout 60s
39+
40+
echo
41+
echo 'waiting for database recovery'
42+
sleep 30
43+
44+
# deploy the Res-Edge Data Service
45+
kubectl apply -k api
46+
47+
echo
48+
echo 'waiting for api pod to start'
49+
50+
# wait for pod to start
51+
kubectl wait pod --all --for condition=ready -n api --timeout 60s
52+
53+
# deploy webv
54+
kubectl apply -k webv
55+
56+
echo
57+
echo "Waiting for pods to start"
58+
kubectl wait pod --all --for condition=ready -n logging --timeout 60s
59+
kubectl wait pod --all --for condition=ready -n monitoring --timeout 30s
60+
kubectl wait pod --all --for condition=ready -n api --timeout 60s

.devcontainer/post-create.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ echo "update CLI"
1919
echo "update oh-my-zsh"
2020
git -C "$HOME/.oh-my-zsh" pull
2121

22+
# todo - remove once bug is fixed
23+
# downgrade urllib for http bug
24+
pip install 'urllib3<2'
25+
2226
echo "post-create complete"
2327
echo "$(date +'%Y-%m-%d %H:%M:%S') post-create complete" >> "$HOME/status"

.ds/commands/res-edge/entity-list

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
#!/bin/bash
2+
23
PARENT_COMMAND=$(ps -o comm= $PPID)
34

45
usage() {
5-
echo "Usage: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} [--search search term] [--order-by name]"
6+
echo
7+
8+
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
9+
echo "Usage: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} [--search 'search term'] [--order-by id | name | path]"
10+
else
11+
echo "Usage: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} [--search 'search term'] [--order-by id | name]"
12+
fi
613

7-
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "clusters" ] || [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
8-
echo " or: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} --group [name]"
14+
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "clusters" ]; then
15+
echo " or: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} --group name"
916
echo ' --group: filter clusters by group'
1017
fi
1118

12-
echo " --search: Search for ${KIC_RES_EDGE_ENTITYNAME} by name, metadata or tag. Optional."
13-
echo ' --order-by: Order by name. Optional. Default: id.'
19+
echo " --search: Search ${KIC_RES_EDGE_ENTITYNAME} by name, metadata or tag (optional)"
20+
21+
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
22+
echo ' --order-by: id | name | path (default: id)'
23+
else
24+
echo ' --order-by: id | name (default: id)'
25+
fi
26+
27+
echo
28+
1429
exit 1
1530
}
1631

1732
list_clusters() {
18-
1933
CLUSTERS=$(curl --silent --show-error "$URL" | jq -r ' .value[] | .clustersTree' )
2034

2135
if [ "$CLUSTERS" = "" ]; then
@@ -26,18 +40,19 @@ list_clusters() {
2640
CLUSTERS=${CLUSTERS:1}
2741
CLUSTERS=${CLUSTERS::-1}
2842

29-
echo "ID NAME"
30-
echo "-- ------"
3143
for s in $(echo "{$CLUSTERS}" | sed "s/,/\n/g"); do echo "$s" | sed "s=\/api=${DS_URL}\/api=g" | xargs curl -s | jq -r '([.id, .name]) | @tsv'; done
3244
}
3345

3446
list() {
3547
if [ -n "${GROUP}" ]; then
3648
CLUSTERS=$(list_clusters)
37-
echo "$CLUSTERS"
49+
echo "$CLUSTERS" | column -t -s $'\t' -N Id,Name -R Id -o ' '
50+
elif [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
51+
response=$(curl --silent --show-error "$URL" | jq -r '(.value[] | [.id, .name, .namePath]) | @tsv')
52+
echo "$response" | column -t -s $'\t' -N Id,Name,Path -R Id -o ' '
3853
else
39-
response=$(curl --silent --show-error "$URL" | jq -r '["ID","NAME"], ["--","------"], (.value[] | [.id, .name]) | @tsv')
40-
echo "$response"
54+
response=$(curl --silent --show-error "$URL" | jq -r '(.value[] | [.id, .name]) | @tsv')
55+
echo "$response" | column -t -s $'\t' -N Id,Name -R Id -o ' '
4156
fi
4257
}
4358

@@ -54,7 +69,14 @@ for arg in "$@"; do
5469
set -- "${@/$arg/-o}"
5570
;;
5671
--group)
57-
set -- "${@/$arg/-g}"
72+
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "clusters" ]; then
73+
set -- "${@/$arg/-g}"
74+
else
75+
echo
76+
echo "Error: --group is not a valid parameter"
77+
echo
78+
usage
79+
fi
5880
;;
5981
esac
6082
done
@@ -73,8 +95,15 @@ while getopts ":s:o:g:" f; do
7395
done
7496
shift $((OPTIND-1))
7597

76-
if [ -n "$ORDERBY" ] && [ "$ORDERBY" != "id" ] && [ "$ORDERBY" != "name" ]; then
77-
echo "Error: Order by supports either 'id' or 'name'."
98+
if [ "$KIC_RES_EDGE_ENTITYNAME" = "groups" ]; then
99+
if [ "$KIC_RES_EDGE_ENTITYNAME" = "groups" ] && [ -n "$ORDERBY" ] && [ "$ORDERBY" != "id" ] && [ "$ORDERBY" != "name" ] && [ "$ORDERBY" != "path" ]; then
100+
echo
101+
echo "Error: Order by supports either 'id' 'name' or 'path'"
102+
usage
103+
fi
104+
elif [ -n "$ORDERBY" ] && [ "$ORDERBY" != "id" ] && [ "$ORDERBY" != "name" ]; then
105+
echo
106+
echo "Error: Order by supports either 'id' or 'name'"
78107
usage
79108
fi
80109

@@ -85,7 +114,11 @@ if [ -n "${SEARCH}" ]; then
85114
fi
86115

87116
if [ -n "${ORDERBY}" ]; then
88-
URL_PARAMS+=("orderby=${ORDERBY}")
117+
if [ "$ORDERBY" = "path" ]; then
118+
URL_PARAMS+=("orderby=namePath")
119+
else
120+
URL_PARAMS+=("orderby=${ORDERBY}")
121+
fi
89122
fi
90123

91124
if [ -n "${GROUP}" ]; then
@@ -106,7 +139,10 @@ URL_QUERY_STRING=${URL_QUERY_STRING:1}
106139
URL="${KIC_BASE_URL}?${URL_QUERY_STRING}"
107140

108141
if ! list; then
142+
echo
109143
echo "Error: Failed to retrieve data from $URL"
110144
echo "Please check that the Res-Edge server is up and running with: kic check resedge"
145+
echo
146+
111147
exit 1
112148
fi

.github/workflows/gitops.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ The first lab is an `inner-loop` lab that introduces Codespaces and the various
101101
- Configuration Proliferation
102102
- Connectivity
103103

104-
[Lab](./labs/deploy-res-edge/README.md#inner-loop-with-res-edge): Deploy Resilient Edge Data Service to Codespaces
104+
[Lab](./labs/deploy-res-edge.md#inner-loop-with-res-edge): Deploy Resilient Edge Data Service to Codespaces
105105

106106
## Assign a Group to a Namespace
107107

@@ -122,6 +122,22 @@ Application teams often want to deploy new versions of their app(s) to a growing
122122

123123
[Lab](./labs/ring-deployment-with-kustomize.md#ring-deployment-with-kustomize): Ring deployment with Res-Edge and Kustomize
124124

125+
## Register new Namespace and Applications
126+
127+
Application teams need to register new Namespaces and Applications in the Res-Edge Data Service in order to deploy their apps.
128+
129+
- In this lab, we will register a new Namespace and two new Applications to the Data Service
130+
131+
[Lab](./labs/register-namespace-and-applications.md#register-a-new-namespace-and-applications): Register a new Namespace and Applications
132+
133+
## Deploy via GitOps (Flux)
134+
135+
## GitOps Lab
136+
137+
- In this lab, we will use GitOps (Flux) to deploy the Namespaces and Applications assigned to a Cluster
138+
139+
[Lab](./labs/gitops.md#gitops-lab): Deploy via GitOps
140+
125141
## Support
126142

127143
This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.

apps/go-vote/kustomize/prod/base/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
spec:
2323
containers:
2424
- name: app
25-
image: ghcr.io/cse-labs/go-vote:latest
25+
image: ghcr.io/cse-labs/go-vote:0.2.0
2626
imagePullPolicy: Always
2727
args:
2828
- key1

apps/heartbeat/kustomize/prod/base/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
spec:
2323
containers:
2424
- name: app
25-
image: ghcr.io/cse-labs/heartbeat:latest
25+
image: ghcr.io/cse-labs/heartbeat:0.1.0
2626
imagePullPolicy: Always
2727
ports:
2828
- name: http

clusters/central-la-nola-2301/flux-system/listeners/kustomization-imdb.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

clusters/central-la-nola-2301/heartbeat/heartbeat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
app: heartbeat
3838
spec:
3939
containers:
40-
- image: ghcr.io/cse-labs/heartbeat:latest
40+
- image: ghcr.io/cse-labs/heartbeat:0.1.0
4141
imagePullPolicy: Always
4242
livenessProbe:
4343
failureThreshold: 10

clusters/central-la-nola-2301/imdb/imdb.yaml

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)