diff --git a/docs/tutorials/hello-tye/postgres.yaml b/docs/tutorials/hello-tye/postgres.yaml new file mode 100644 index 00000000..1cf670d4 --- /dev/null +++ b/docs/tutorials/hello-tye/postgres.yaml @@ -0,0 +1,43 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: postgres + labels: + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: microservice +spec: + selector: + matchLabels: + app.kubernetes.io/name: postgres + replicas: 1 + template: + metadata: + labels: + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: microservice + spec: + containers: + - name: postgres + image: postgres + ports: + - containerPort: 5432 + env: + - name: POSTGRES_USER + value: postgres + - name: POSTGRES_PASSWORD + value: pass@word1 + +--- +apiVersion: v1 +kind: Service +metadata: + name: postgres + labels: + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: microservice +spec: + ports: + - port: 5432 + targetPort: 5432 + selector: + app.kubernetes.io/name: postgres diff --git a/samples/voting/README.md b/samples/voting/README.md index 144b0747..2b9f38df 100644 --- a/samples/voting/README.md +++ b/samples/voting/README.md @@ -1,4 +1,5 @@ # VotingSample + Voting sample app inspired by https://github.com/dockersamples/example-voting-app with a few different implementation choices. ## For running @@ -9,11 +10,49 @@ The project should be immediately runnable by calling `tye run` from the directo A few things need to be configured before deploying to Kubernetes. -- Setting up Redis. A connection string needs to be provided to connect to Redis. You can follow our tutorial on [setting up redis in your cluster](../../docs/tutorials/hello-tye/02_add_redis.md). -- Setting up postgresql. A connection string eventually needs to be provided to tye for postgresql. -- Deploying the ingress.yaml by calling: +- [Create an Azure container registry using the Azure portal](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal) or you can use your public [docker hub account](https://hub.docker.com/) + +- You can use managed service instances for both `redis` and `postgres` datastore. For e.g : + + - `redis` : *Azure Cache for Redis* + - `postgres`: *Azure Database for PostgreSQL* + + Or you can use the following steps to deploy the respective datastores in the Kubernetes cluster itself. + +- `Redis` can be deployed using the below command : ``` - kubectl apply -f ingress.yml + kubectl apply -f https://raw.githubusercontent.com/dotnet/tye/master/docs/tutorials/hello-tye/redis.yaml ``` +- `Postgresql` can be installed by the following command : + + ``` + kubectl apply -f https://raw.githubusercontent.com/dotnet/tye/master/docs/tutorials/hello-tye/postgres.yaml + ``` + +- Once the deployment is done, you need to keep a note of the below connection strings : + + - `redis:6379` + - `Server=postgres;Port=5432;User Id=postgres;Password=pass@word1;` + + >! NOTE: You can modify the password in `postgres` yaml. + +- After that, run `tye deploy --interactive` to do the deployment. +- Fill in the value of container registry and connection strings for both `redis` and `postgres` when it's prompted. + +- Once the deployment is complete you should be able to find the public IP address of the deployed application by using : + + ``` + kubectl get all -n ingress-nginx + ``` + + ![nginx ingress example](../../docs/recipes/images/nginx_ingress_action.png) + + Look for the `service/ingress-nginx-controller` with a type of `LoadBalancer`. The `EXTERNAL-IP` is the entry point for your application. + For e.g : + + - vote : http://\/vote + - result: http://\/results + + >! NOTE: Ingress controller may take a while to update the listed public IP address. \ No newline at end of file diff --git a/samples/voting/ingress.yml b/samples/voting/ingress.yml deleted file mode 100644 index 704b8831..00000000 --- a/samples/voting/ingress.yml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: ingress-basic - namespace: default - annotations: - kubernetes.io/ingress.class: nginx - nginx.ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/rewrite-target: /$2 -spec: - rules: - - http: - paths: - - backend: - serviceName: vote - servicePort: 80 - path: /vote(/|$)(.*) - - backend: - serviceName: results - servicePort: 80 - path: /results(/|$)(.*) \ No newline at end of file diff --git a/samples/voting/tye.yaml b/samples/voting/tye.yaml index f8eb59e4..d6020f04 100644 --- a/samples/voting/tye.yaml +++ b/samples/voting/tye.yaml @@ -1,4 +1,13 @@ name: VotingSample +ingress: + - name: ingress + bindings: + - port: 8080 + rules: + - path: /vote + service: vote + - path: /results + service: results services: - name: vote project: vote/vote.csproj diff --git a/samples/voting/vote/vote.csproj b/samples/voting/vote/vote.csproj index ed4c23aa..90f4c070 100644 --- a/samples/voting/vote/vote.csproj +++ b/samples/voting/vote/vote.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 Vote diff --git a/samples/voting/worker/worker.csproj b/samples/voting/worker/worker.csproj index fe7d9b49..74a7efaa 100644 --- a/samples/voting/worker/worker.csproj +++ b/samples/voting/worker/worker.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 dotnet-worker-A47A7C4B-4BF2-4243-9BBE-E6B3CB3E9C6F Worker