Browse Source

Updated Voting sample deployment steps (#755)

pull/824/head
Sumit Ghosh 6 years ago
committed by GitHub
parent
commit
112857f021
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      docs/tutorials/hello-tye/postgres.yaml
  2. 47
      samples/voting/README.md
  3. 21
      samples/voting/ingress.yml
  4. 9
      samples/voting/tye.yaml
  5. 2
      samples/voting/vote/vote.csproj
  6. 2
      samples/voting/worker/worker.csproj

43
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

47
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://\<EXTERNAL-IP\>/vote
- result: http://\<EXTERNAL-IP\>/results
>! NOTE: Ingress controller may take a while to update the listed public IP address.

21
samples/voting/ingress.yml

@ -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(/|$)(.*)

9
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

2
samples/voting/vote/vote.csproj

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Vote</RootNamespace>
</PropertyGroup>

2
samples/voting/worker/worker.csproj

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>dotnet-worker-A47A7C4B-4BF2-4243-9BBE-E6B3CB3E9C6F</UserSecretsId>
<RootNamespace>Worker</RootNamespace>
</PropertyGroup>

Loading…
Cancel
Save