Skip to content

Commit

Permalink
new lab - registering Namespace and Applications (#84)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored May 20, 2023
1 parent 7f57a9e commit d490ddb
Show file tree
Hide file tree
Showing 158 changed files with 451 additions and 25,565 deletions.
60 changes: 60 additions & 0 deletions .devcontainer/deploy-res-edge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Warning: this is a destructive command

# This script will create a new cluster and deploy Res-Edge Data Service
# Any prior data service changes will be overwritten and are not recoverable
# Use the --force flag to make the database changes

# a little protection
if [ "$1" != "--force" ]; then
echo ""
echo "This is a destructive command that deletes your current cluster"
econ "and creates a new cluster with Res-Edge Data Service deployed"
echo ""
echo "Usage: .devcontainer/deploy-res-edge.sh --force"
echo ""
exit 1
fi

set -e

cd "$KIC_BASE/deploy" || exit 1

# delete and create a new cluster
kic cluster create

# create the namespace
kubectl apply -f ns.yaml

# deploy SQL Server with sample data
kubectl apply -k mssql

# deploy monitoring and logging
kubectl apply -k monitoring

echo
echo 'waiting for mssql pod to start'
kubectl wait pod --all --for condition=ready -n api --timeout 60s

echo
echo 'waiting for database recovery'
sleep 30

# deploy the Res-Edge Data Service
kubectl apply -k api

echo
echo 'waiting for api pod to start'

# wait for pod to start
kubectl wait pod --all --for condition=ready -n api --timeout 60s

# deploy webv
kubectl apply -k webv

echo
echo "Waiting for pods to start"
kubectl wait pod --all --for condition=ready -n logging --timeout 60s
kubectl wait pod --all --for condition=ready -n monitoring --timeout 30s
kubectl wait pod --all --for condition=ready -n api --timeout 60s
4 changes: 4 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ echo "update CLI"
echo "update oh-my-zsh"
git -C "$HOME/.oh-my-zsh" pull

# todo - remove once bug is fixed
# downgrade urllib for http bug
pip install 'urllib3<2'

echo "post-create complete"
echo "$(date +'%Y-%m-%d %H:%M:%S') post-create complete" >> "$HOME/status"
66 changes: 51 additions & 15 deletions .ds/commands/res-edge/entity-list
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
#!/bin/bash

PARENT_COMMAND=$(ps -o comm= $PPID)

usage() {
echo "Usage: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} [--search search term] [--order-by name]"
echo

if [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
echo "Usage: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} [--search 'search term'] [--order-by id | name | path]"
else
echo "Usage: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} [--search 'search term'] [--order-by id | name]"
fi

if [ "${KIC_RES_EDGE_ENTITYNAME}" = "clusters" ] || [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
echo " or: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} --group [name]"
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "clusters" ]; then
echo " or: kic ${KIC_RES_EDGE_ENTITYNAME} ${PARENT_COMMAND} --group name"
echo ' --group: filter clusters by group'
fi

echo " --search: Search for ${KIC_RES_EDGE_ENTITYNAME} by name, metadata or tag. Optional."
echo ' --order-by: Order by name. Optional. Default: id.'
echo " --search: Search ${KIC_RES_EDGE_ENTITYNAME} by name, metadata or tag (optional)"

if [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
echo ' --order-by: id | name | path (default: id)'
else
echo ' --order-by: id | name (default: id)'
fi

echo

exit 1
}

list_clusters() {

CLUSTERS=$(curl --silent --show-error "$URL" | jq -r ' .value[] | .clustersTree' )

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

echo "ID NAME"
echo "-- ------"
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
}

list() {
if [ -n "${GROUP}" ]; then
CLUSTERS=$(list_clusters)
echo "$CLUSTERS"
echo "$CLUSTERS" | column -t -s $'\t' -N Id,Name -R Id -o ' '
elif [ "${KIC_RES_EDGE_ENTITYNAME}" = "groups" ]; then
response=$(curl --silent --show-error "$URL" | jq -r '(.value[] | [.id, .name, .namePath]) | @tsv')
echo "$response" | column -t -s $'\t' -N Id,Name,Path -R Id -o ' '
else
response=$(curl --silent --show-error "$URL" | jq -r '["ID","NAME"], ["--","------"], (.value[] | [.id, .name]) | @tsv')
echo "$response"
response=$(curl --silent --show-error "$URL" | jq -r '(.value[] | [.id, .name]) | @tsv')
echo "$response" | column -t -s $'\t' -N Id,Name -R Id -o ' '
fi
}

Expand All @@ -54,7 +69,14 @@ for arg in "$@"; do
set -- "${@/$arg/-o}"
;;
--group)
set -- "${@/$arg/-g}"
if [ "${KIC_RES_EDGE_ENTITYNAME}" = "clusters" ]; then
set -- "${@/$arg/-g}"
else
echo
echo "Error: --group is not a valid parameter"
echo
usage
fi
;;
esac
done
Expand All @@ -73,8 +95,15 @@ while getopts ":s:o:g:" f; do
done
shift $((OPTIND-1))

if [ -n "$ORDERBY" ] && [ "$ORDERBY" != "id" ] && [ "$ORDERBY" != "name" ]; then
echo "Error: Order by supports either 'id' or 'name'."
if [ "$KIC_RES_EDGE_ENTITYNAME" = "groups" ]; then
if [ "$KIC_RES_EDGE_ENTITYNAME" = "groups" ] && [ -n "$ORDERBY" ] && [ "$ORDERBY" != "id" ] && [ "$ORDERBY" != "name" ] && [ "$ORDERBY" != "path" ]; then
echo
echo "Error: Order by supports either 'id' 'name' or 'path'"
usage
fi
elif [ -n "$ORDERBY" ] && [ "$ORDERBY" != "id" ] && [ "$ORDERBY" != "name" ]; then
echo
echo "Error: Order by supports either 'id' or 'name'"
usage
fi

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

if [ -n "${ORDERBY}" ]; then
URL_PARAMS+=("orderby=${ORDERBY}")
if [ "$ORDERBY" = "path" ]; then
URL_PARAMS+=("orderby=namePath")
else
URL_PARAMS+=("orderby=${ORDERBY}")
fi
fi

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

if ! list; then
echo
echo "Error: Failed to retrieve data from $URL"
echo "Please check that the Res-Edge server is up and running with: kic check resedge"
echo

exit 1
fi
41 changes: 0 additions & 41 deletions .github/workflows/gitops.yaml

This file was deleted.

18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The first lab is an `inner-loop` lab that introduces Codespaces and the various
- Configuration Proliferation
- Connectivity

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

## Assign a Group to a Namespace

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

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

## Register new Namespace and Applications

Application teams need to register new Namespaces and Applications in the Res-Edge Data Service in order to deploy their apps.

- In this lab, we will register a new Namespace and two new Applications to the Data Service

[Lab](./labs/register-namespace-and-applications.md#register-a-new-namespace-and-applications): Register a new Namespace and Applications

## Deploy via GitOps (Flux)

## GitOps Lab

- In this lab, we will use GitOps (Flux) to deploy the Namespaces and Applications assigned to a Cluster

[Lab](./labs/gitops.md#gitops-lab): Deploy via GitOps

## Support

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.
Expand Down
2 changes: 1 addition & 1 deletion apps/go-vote/kustomize/prod/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
spec:
containers:
- name: app
image: ghcr.io/cse-labs/go-vote:latest
image: ghcr.io/cse-labs/go-vote:0.2.0
imagePullPolicy: Always
args:
- key1
Expand Down
2 changes: 1 addition & 1 deletion apps/heartbeat/kustomize/prod/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
spec:
containers:
- name: app
image: ghcr.io/cse-labs/heartbeat:latest
image: ghcr.io/cse-labs/heartbeat:0.1.0
imagePullPolicy: Always
ports:
- name: http
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion clusters/central-la-nola-2301/heartbeat/heartbeat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
app: heartbeat
spec:
containers:
- image: ghcr.io/cse-labs/heartbeat:latest
- image: ghcr.io/cse-labs/heartbeat:0.1.0
imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
Expand Down
73 changes: 0 additions & 73 deletions clusters/central-la-nola-2301/imdb/imdb.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions clusters/central-la-nola-2301/namespaces/imdb.yaml

This file was deleted.

Loading

0 comments on commit d490ddb

Please sign in to comment.