Skip to content

Commit

Permalink
add manifest to depoy microservice
Browse files Browse the repository at this point in the history
  • Loading branch information
meofiscoding committed Nov 19, 2023
1 parent 60624c8 commit e7fcb31
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 44 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/payment-api-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy payment-api to k8s

on:
workflow_dispatch:
push:
branches:
- main

paths:
- .github/workflows/payment-api-deploy.yml
- .github/workflows/composite/deploy/action.yml
- deploy/k8s/payment-service.yaml
- SimpleServer/src/Services/Payment/Payment.API/**

env:
NAMESPACE: ingress-nginx

jobs:
deploy-to-k8s:
permissions:
actions: read
# contents: read
id-token: write
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

# Logs in with your Azure credentials
- name: Azure login
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- uses: ./.github/workflows/composite/deploy
with:
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
cluster_name: ${{ secrets.CLUSTER_NAME }}
resource_group: ${{ secrets.RESOURCE_GROUP }}
manifest_path: |
deploy/k8s/postgres-secret.yaml
deploy/k8s/postgres-configmap.yaml
deploy/k8s/postgresql.yaml
deploy/k8s/stripe-secret.yaml
deploy/k8s/payment-service.yaml
registry_endpoint: ${{ secrets.REGISTRY_ENDPOINT }}
namespace: ${{ env.NAMESPACE }}
image_name: movie.api
deployment_name: movie-api-deployment
service_name: movie-api-service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Routes": [
{
"DownstreamPathTemplate": "/api/pricingPlans",
"DownstreamPathTemplate": "/api/pricingPlan/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
Expand All @@ -12,7 +12,7 @@
"UpstreamHttpMethod": [
"GET"
],
"UpstreamPathTemplate": "/payment/planform/{everything}",
"UpstreamPathTemplate": "/payment/plan/{everything}",
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
Expand Down Expand Up @@ -105,12 +105,9 @@
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
// Uncomment this to use the local api
"Host": "localhost",
"Port": 8000
// Uncomment this to use the docker container
// "Host": "movie.api",
// "Port": 80
"Host": "movie.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/movies",
Expand Down
2 changes: 1 addition & 1 deletion deploy/k8s/apigw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- containerPort: 80
env:
- name: IdentityUrl
value: https://frontend.20.211.61.204.nip.io
value: https://netflix-identity.azurewebsites.net
- name: ASPNETCORE_ENVIRONMENT
value: Production
- name: OCELOT_CONFIG_PATH
Expand Down
137 changes: 102 additions & 35 deletions deploy/k8s/ocelot-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,106 @@ metadata:
data:
ocelot.Production.json: |-
{
"Routes": [
{
"DownstreamPathTemplate": "/api/movie",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "movie-api-service",
"Port": 80
}
],
"UpstreamPathTemplate": "/movies",
"UpstreamHttpMethod": [
"GET",
"POST",
"PUT"
],
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
"movies"
]
}
},
{
"DownstreamPathTemplate": "/",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "identity-grpc-service",
"Port": 80
"Routes": [
{
"DownstreamPathTemplate": "/api/pricingPlan/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "payment-api-service",
"Port": 80
}
],
"UpstreamHttpMethod": [
"GET"
],
"UpstreamPathTemplate": "/payment/plan/{everything}",
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
"payment"
]
}
],
"UpstreamPathTemplate": "/identity-grpc",
}
]
}
},
{
"DownstreamPathTemplate": "/api/pricingPlans",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "payment-api-service",
"Port": 80
}
],
"UpstreamHttpMethod": [
"GET"
],
"UpstreamPathTemplate": "/payment/planform",
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
"payment"
]
}
},
{
"DownstreamPathTemplate": "/api/subscription",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "payment-api-service",
"Port": 80
}
],
"UpstreamHttpMethod": [
"POST"
],
"UpstreamPathTemplate": "/payment/subscriptions",
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
"payment"
]
}
},
{
"DownstreamPathTemplate": "/api/create-payment-intent",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "payment-api-service",
"Port": 80
}
],
"UpstreamHttpMethod": [
"POST"
],
"UpstreamPathTemplate": "/payment/checkout",
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
"payment"
]
}
},
{
"DownstreamPathTemplate": "/subscription/success",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "payment-api-service",
"Port": 80
}
],
"UpstreamHttpMethod": [
"POST"
],
"UpstreamPathTemplate": "/payment/success",
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": [
"payment"
]
}
},
]
}
60 changes: 60 additions & 0 deletions deploy/k8s/payment-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: payment-api-deployment
namespace: ingress-nginx
labels:
app: payment-api
spec:
replicas: 1
selector:
matchLabels:
app: payment-api
template:
metadata:
labels:
app: payment-api
spec:
containers:
- name: paymentapi
image: 281901/payment.api:dev
imagePullPolicy: Always
ports:
- containerPort: 80
env:
- name: IdentityUrl
value: https://netflix-identity.azurewebsites.net
- name: ASPNETCORE_URLS
value: "http://+:50051;http://+:80"
- name: Stripe__SecretKey
valueFrom:
secretKeyRef:
name: stripe-secret
key: secret_key
- name: ConnectionStrings__PaymentDB
valueFrom:
configMapKeyRef:
name: postgres-configmap
key: connection_string
- name: GrpcUrl
value: http://identity-grpc-service:80
resources:
requests:
memory: "64Mi"
cpu: "0.1"
limits:
memory: "128Mi"
cpu: "0.3"
---
apiVersion: v1
kind: Service
metadata:
name: payment-api-service
namespace: ingress-nginx
spec:
type: ClusterIP
selector:
app: payment-api
ports:
- protocol: TCP
port: 80
2 changes: 1 addition & 1 deletion deploy/k8s/postgres-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: postgres-configmap
namespace: ingress-nginx
data:
connection_string: User ID=postgres;Password=123456;Server=postgres-service ;Port=5432;Database=IdentityDB;
connection_string: User ID=postgres;Password=123456;Server=postgres-service ;Port=5432;Database=PaymentDB;
8 changes: 8 additions & 0 deletions deploy/k8s/stripe-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: stripe-secret
namespace: ingress-nginx
type: Opaque
data:
secret_key: c2tfdGVzdF81MU9CRVhkSGx2V241elZ5MHR6NVhncXB2T1AxQko3emVNanZYS2F5ZEpqYWxHNjRGaTQzMEJlOG4wTGx3Y3ZGRXNqN3BFRWhyRDNLbUEzaHY1T0VzNXUzSTAwWTFjRTg3aWk=

0 comments on commit e7fcb31

Please sign in to comment.