From fc01c691e63f1bbc037eaa068f00cfe97c8bbbb4 Mon Sep 17 00:00:00 2001 From: Reshma Abdul Rahim <61033581+Reshrahim@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:32:26 -0400 Subject: [PATCH] Downmerge 10-24 (#702) * k8s guestbook application example for use in tutorial (#626) * copy over k8s guestbook application example for use in tutorial Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jonathan Smith --------- Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> Co-authored-by: Jonathan Smith * Upmerge 10-24 (#695) * Update get.radapp.dev references (#625) * Update get.radapp.dev refernces * Update vscode extension install * Update eShop Readme with new url links (#647) * Fix edge version download (#685) * Add Kuberenetes tutorial content (#620) * Add Kuberenetes tutorial content * Update demo/Chart/values.yaml Co-authored-by: Aaron Crawfis * Update demo/Chart/values.yaml Co-authored-by: Aaron Crawfis * k8s guestbook application example for use in tutorial (#626) * copy over k8s guestbook application example for use in tutorial Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jonathan Smith --------- Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> Co-authored-by: Jonathan Smith * Rebase to v0.26 * move chat templatesto samples --------- Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> Co-authored-by: Aaron Crawfis Co-authored-by: Will <28876888+willtsai@users.noreply.github.com> Co-authored-by: Jonathan Smith Co-authored-by: Reshma Abdul Rahim Co-authored-by: Reshma Abdul Rahim <61033581+Reshrahim@users.noreply.github.com> * Revert changes to test.yaml --------- Signed-off-by: Aaron Crawfis Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> Co-authored-by: Aaron Crawfis Co-authored-by: James Montemagno Co-authored-by: Ryan Nowak Co-authored-by: Will <28876888+willtsai@users.noreply.github.com> Co-authored-by: Jonathan Smith * Added a condition to allow Docker to fully setup during post-create before initializing the K3d cluster (#694) Co-authored-by: Reshma Abdul Rahim <61033581+Reshrahim@users.noreply.github.com> --------- Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> Signed-off-by: Aaron Crawfis Co-authored-by: Will <28876888+willtsai@users.noreply.github.com> Co-authored-by: Jonathan Smith Co-authored-by: Aaron Crawfis Co-authored-by: James Montemagno Co-authored-by: Ryan Nowak Co-authored-by: jasonviviano <83607984+jasonviviano@users.noreply.github.com> --- .devcontainer/post-create.sh | 9 +++-- samples/README.md | 2 +- samples/kubernetes/guestbook/README.md | 5 +++ .../guestbook/deploy/frontend-deployment.yaml | 33 +++++++++++++++++ .../guestbook/deploy/frontend-service.yaml | 18 ++++++++++ .../deploy/redis-master-deployment.yaml | 27 ++++++++++++++ .../deploy/redis-master-service.yaml | 16 +++++++++ .../deploy/redis-replica-deployment.yaml | 35 +++++++++++++++++++ .../deploy/redis-replica-service.yaml | 15 ++++++++ 9 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 samples/kubernetes/guestbook/README.md create mode 100644 samples/kubernetes/guestbook/deploy/frontend-deployment.yaml create mode 100644 samples/kubernetes/guestbook/deploy/frontend-service.yaml create mode 100644 samples/kubernetes/guestbook/deploy/redis-master-deployment.yaml create mode 100644 samples/kubernetes/guestbook/deploy/redis-master-service.yaml create mode 100644 samples/kubernetes/guestbook/deploy/redis-replica-deployment.yaml create mode 100644 samples/kubernetes/guestbook/deploy/redis-replica-service.yaml diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index 44826f18..26e3a7ee 100644 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -1,8 +1,13 @@ #!/bin/sh ## Create a k3d cluster -k3d cluster delete -k3d cluster create -p '8081:80@loadbalancer' --k3s-arg '--disable=traefik@server:0' +while (! kubectl cluster-info ); do + # Docker takes a few seconds to initialize + echo "Waiting for Docker to launch..." + k3d cluster delete + k3d cluster create -p '8081:80@loadbalancer' --k3s-arg '--disable=traefik@server:0' + sleep 1 +done ## Install Dapr and init wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash diff --git a/samples/README.md b/samples/README.md index bca12942..5c1bd27e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -1,6 +1,6 @@ # Reference applications -Reference apps are templates that show a complete app. You are able to clone and deploy any of these apps to try out various Project Radius functionality. +Clone and deploy reference applications to learn more about Radius. | Reference app | Description | |---------------|-------------| diff --git a/samples/kubernetes/guestbook/README.md b/samples/kubernetes/guestbook/README.md new file mode 100644 index 00000000..34b0c930 --- /dev/null +++ b/samples/kubernetes/guestbook/README.md @@ -0,0 +1,5 @@ +# Kubernetes Guestbook application example + +This is an example containerized Guestbook application originally authored by the Kubernetes community for use in their own tutorial. The application's Kubernetes deployment manifests copied over from the Kubernetes source [repo](https://github.com/kubernetes/examples/tree/master/guestbook) are contained in the `deploy` directory. + +The Guestbook application consists of a web front end along with primary and secondary Redis containers for storage, all deployed with Kubernetes. For more information about the application and accessing its source code, see the [Kubernetes tutorial](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/) and their [examples repo](https://github.com/kubernetes/examples/tree/master/guestbook). \ No newline at end of file diff --git a/samples/kubernetes/guestbook/deploy/frontend-deployment.yaml b/samples/kubernetes/guestbook/deploy/frontend-deployment.yaml new file mode 100644 index 00000000..2b08cc9d --- /dev/null +++ b/samples/kubernetes/guestbook/deploy/frontend-deployment.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1 +kind: Deployment +metadata: + name: frontend +spec: + selector: + matchLabels: + app: guestbook + tier: frontend + replicas: 3 + template: + metadata: + labels: + app: guestbook + tier: frontend + spec: + containers: + - name: php-redis + image: gcr.io/google-samples/gb-frontend:v4 + resources: + requests: + cpu: 100m + memory: 100Mi + env: + - name: GET_HOSTS_FROM + value: dns + # If your cluster config does not include a dns service, then to + # instead access environment variables to find service host + # info, comment out the 'value: dns' line above, and uncomment the + # line below: + # value: env + ports: + - containerPort: 80 diff --git a/samples/kubernetes/guestbook/deploy/frontend-service.yaml b/samples/kubernetes/guestbook/deploy/frontend-service.yaml new file mode 100644 index 00000000..dca33530 --- /dev/null +++ b/samples/kubernetes/guestbook/deploy/frontend-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: frontend + labels: + app: guestbook + tier: frontend +spec: + # comment or delete the following line if you want to use a LoadBalancer + type: NodePort + # if your cluster supports it, uncomment the following to automatically create + # an external load-balanced IP for the frontend service. + # type: LoadBalancer + ports: + - port: 80 + selector: + app: guestbook + tier: frontend diff --git a/samples/kubernetes/guestbook/deploy/redis-master-deployment.yaml b/samples/kubernetes/guestbook/deploy/redis-master-deployment.yaml new file mode 100644 index 00000000..5a76f05d --- /dev/null +++ b/samples/kubernetes/guestbook/deploy/redis-master-deployment.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1 +kind: Deployment +metadata: + name: redis-master +spec: + selector: + matchLabels: + app: redis + role: master + tier: backend + replicas: 1 + template: + metadata: + labels: + app: redis + role: master + tier: backend + spec: + containers: + - name: master + image: registry.k8s.io/redis:e2e # or just image: redis + resources: + requests: + cpu: 100m + memory: 100Mi + ports: + - containerPort: 6379 diff --git a/samples/kubernetes/guestbook/deploy/redis-master-service.yaml b/samples/kubernetes/guestbook/deploy/redis-master-service.yaml new file mode 100644 index 00000000..a484014f --- /dev/null +++ b/samples/kubernetes/guestbook/deploy/redis-master-service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis-master + labels: + app: redis + role: master + tier: backend +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: redis + role: master + tier: backend diff --git a/samples/kubernetes/guestbook/deploy/redis-replica-deployment.yaml b/samples/kubernetes/guestbook/deploy/redis-replica-deployment.yaml new file mode 100644 index 00000000..c1e8ca31 --- /dev/null +++ b/samples/kubernetes/guestbook/deploy/redis-replica-deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1 +kind: Deployment +metadata: + name: redis-replica +spec: + selector: + matchLabels: + app: redis + role: replica + tier: backend + replicas: 2 + template: + metadata: + labels: + app: redis + role: replica + tier: backend + spec: + containers: + - name: slave + image: gcr.io/google_samples/gb-redisslave:v1 + resources: + requests: + cpu: 100m + memory: 100Mi + env: + - name: GET_HOSTS_FROM + value: dns + # If your cluster config does not include a dns service, then to + # instead access an environment variable to find the master + # service's host, comment out the 'value: dns' line above, and + # uncomment the line below: + # value: env + ports: + - containerPort: 6379 diff --git a/samples/kubernetes/guestbook/deploy/redis-replica-service.yaml b/samples/kubernetes/guestbook/deploy/redis-replica-service.yaml new file mode 100644 index 00000000..90172bbf --- /dev/null +++ b/samples/kubernetes/guestbook/deploy/redis-replica-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis-replica + labels: + app: redis + role: replica + tier: backend +spec: + ports: + - port: 6379 + selector: + app: redis + role: replica + tier: backend