Skip to content

Instantly share code, notes, and snippets.

@liladas
Forked from vfarcic/148-dapr.sh
Created November 30, 2022 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liladas/778ebb146dd42eec1d5e578e0920e435 to your computer and use it in GitHub Desktop.
Save liladas/778ebb146dd42eec1d5e578e0920e435 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/8d941690a087b0de0e2731a52cfb1f51
###############################################################
# Building Event-Driven Microservices In Kubernetes With Dapr #
# https://youtu.be/-4sHUvfk2Eg #
###############################################################
# Additional Info:
# - https://dapr.io
# - What is microservices architecture?: https://youtu.be/F-37_gV2tMs
# - How Microservices Communicate? Sync vs Async. Direct vs Brokers And Event Busses: https://youtu.be/6XTGcgt5clQ
#########
# Setup #
#########
git clone https://github.com/vfarcic/dapr-demo
cd dapr-demo
# Create a Kubernetes cluster
# The demo was tested using GKE, but any other Kubernetes cluster should do.
# If you're using a local Kubernetes cluster, please change the `Service` in `apps.yaml` to be `type: NodePort`
kubectl create namespace production
helm repo add dapr \
https://dapr.github.io/helm-charts
helm repo update
helm upgrade --install \
dapr dapr/dapr \
--namespace dapr-system \
--create-namespace \
--wait
helm repo add bitnami \
https://charts.bitnami.com/bitnami
helm repo update
helm upgrade --install \
redis bitnami/redis \
--namespace production \
--create-namespace \
--wait
kubectl --namespace production apply \
--filename redis-dapr.yaml
##################################
# Deploying (Real) Microservices #
##################################
cat apps.yaml
kubectl --namespace production apply \
--filename apps.yaml
kubectl --namespace production \
rollout status \
deployment speech-to-text
kubectl --namespace production \
rollout status \
deployment tweet
kubectl --namespace production \
rollout status \
deployment publications
# The command that follows might differ in EKS and local Kubernetes clusters.
# In EKS, you'll need get retrieve the `hostname` instead of the `ip`.
# Local Kubernetes clusters should be accessible through `127.0.0.1`.
export LB_IP=$(kubectl \
--namespace production \
get svc publications \
--output jsonpath="{.status.loadBalancer.ingress[0].ip}")
curl "http://$LB_IP/addVideo?id=JFALdhtBxR8&name=Rancher&url=https://youtu.be/JFALdhtBxR8"
curl "http://$LB_IP/addPodcast?id=143&name=CI/CD&url=https://www.devopsparadox.com/episodes/how-to-get-started-with-ci-cd-143"
curl "http://$LB_IP/addBlog?name=Rancher&url=https://technologyconversations.com/2022/01/24/how-to-manage-production-grade-kubernetes-clusters-with-rancher"
kubectl --namespace production logs \
--selector app=tweet \
--container tweet \
--tail 20
kubectl --namespace production logs \
--selector app=speech-to-text \
--container speech-to-text \
--tail 20
################################################################
# Microservices Communication With Pub/Sub Events Through Dapr #
################################################################
cat redis-dapr.yaml
cat apps.yaml
cat publications/main.go
cat speech-to-text/main.go
###########
# Destroy #
###########
# Destroy or reset the demo cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment