Sample HATEOS API with swagger OpenAPI documentation and Identity Server.
- Engineering laptop or desktop computer with 16-64GB RAM and Windows 10 or later.
- System administrator rights on laptop or desktop computer.
-
For existing choco, upgrade it
# Execute on PowerShell in admin mode choco upgrade Chocolatey -y
-
For new installation with windows command prompt [CMD]
#Execute on CMD in admin mode @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
-
For new installation with PowerShell
# Execute on PowerShell in admin mode Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
-
For manual installation, download and install it.
-
For existing dotnet sdk, upgrade it
# Execute on PowerShell in admin mode choco upgrade dotnet-7.0-sdk -y
-
With Chocolatey
# Execute on PowerShell in admin mode choco install dotnet-7.0-sdk -y
-
For manual installation, download and install it.
-
For new installation with Chocolatey, Reference.
# Execute on PowerShell in admin mode choco install git -y
-
Install WSL2 on Windows 10
# Execute on PowerShell in admin mode wsl --install
-
Restart your computer to finish the WSL installation on Windows 10 or later.
-
Set up your Linux username and password, Reference.
-
Confirm platform
# Execute on PowerShell in admin mode wsl --list --verbose or wsl -l -v
-
Enable Windows Subsystem for Linux 2, Ignore if already set
# Execute on PowerShell in admin mode wsl --set-default-version 2 or wsl --set-version Ubuntu 2
-
Reference to install WSL2 on windows 10 or later.
-
For manual installation, download and install it.
-
With Chocolatey, Docker Desktop and Docker Engine,
# Execute on PowerShell in admin mode choco install docker-desktop -y
-
After installation,restart your system and run the Docker desktop.
-
Enable Kubernetes(Setting->Kubernetes->Enable Kubernetes).
Note: After installation, keep docker desktop in running state.
-
For existing kubectl, upgrade it
# Execute on PowerShell in admin mode choco upgrade Kubernetes-cli -y # Verify installation kubectl version --client
-
For new installation.
# Execute on PowerShell in admin mode choco install kubernetes-cli -y # Verify installation kubectl version --client
-
Reference document for installation.
-
For new installation.
# Execute on PowerShell in admin mode choco install kubernetes-helm -y # Verify installation helm version
-
For existing helm, upgrade it
# Execute on PowerShell in admin mode choco upgrade Kubernetes-helm -y # Verify installation helm version
-
Reference document for installation.
-
Manually download and install it.
-
With Chocolatey.
# Execute on PowerShell in admin mode choco install ssms -y
-
Start docker desktop [Ignore if it's already running].
-
Start SSMS and try to connect with sql server:
Server: localhost,1433 User: sa Password: Welcome@123
-
For manual installation, download and install it [Recommended].
-
For new installation with Chocolatey, Reference.
choco install visualstudio2022community # or choco install visualstudio2022community --package-parameters "--allWorkloads --includeRecommended --includeOptional --passive --locale en-US"
-
With Chocolatey.
# Execute on PowerShell in admin mode choco install microsoft-windows-terminal -y
-
Reference document to set up it.
-
For manual installation, Download and install it.
-
With Chocolatey.
# Execute on PowerShell in admin mode choco install powershell-core -y
-
For manual installation, Download and install it.
-
With Chocolatey.
# Execute on PowerShell in admin mode choco install openssl -y
-
For manual installation, download and install it.
-
For new installation with Chocolatey, Reference.
choco install github-desktop -y
-
Configure it with your github account.
Note: Use any Git UI tool as per your choice.
-
For manual installation, download and install it.
-
For new installation with Chocolatey, Reference.
# Execute on PowerShell in admin mode choco install lens -y
-
For new installation.
# Execute on PowerShell in admin mode Set-ExecutionPolicy RemoteSigned -scope CurrentUser; powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex" # Verify installation (run this in new terminal) dapr
-
For existing dapr, upgrade it
# Execute on PowerShell in admin mode dapr upgrade
# Execute on PowerShell in admin mode
dapr init
# or
dapr init --slim
# Verify Dapr version
dapr --version
Here, dapr self-hosted mode initialization created dapr_redis,dapr_zipkin. You need to delete them for forever as we will deploy these separately later on.
# Execute on PowerShell in admin mode
dapr init -k
# Verify Dapr version
dapr status -k
kubectl create ns vik
kubectl create ns monitoring
kubectl create ns ingress-nginx
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm repo add kafka-ui https://provectus.github.io/kafka-ui
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm repo list
helm install cert-manager jetstack/cert-manager --namespace vik --version v1.8.2 --set installCRDs=true
Install Ingress controller Ingress Controller
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx --set service.loadBalancerIP='127.0.0.1' --set admissionWebhooks.enabled=false --set extraArgs.enable-ssl-passthrough=false
-
Start docker desktop [Ignore if it's already running].
# Execute on PowerShell in admin mode docker pull mcr.microsoft.com/mssql/server:2019-latest cd C:\install # Git clone this: git clone https://github.com/microsoft/mssql-docker # Navigate to linux based chart. cd .\mssql-docker\linux\sample-helm-chart\ # Helm install this: helm install sqlserver . --set sa_password=Welcome@123 --set pvc.StorageClass=hostpath -n vik # Installed in k8s vik namespace
-
Zookeeper
helm install zookeeper bitnami/zookeeper --set replicaCount=1 --set auth.enabled=false --set allowAnonymousLogin=true -n vik # ZooKeeper can be accessed via port 2181 on the following DNS name from within your cluster: # zookeeper.vik.svc.cluster.local # To connect to your ZooKeeper server from outside the cluster execute the following commands: kubectl port-forward --namespace vik svc/zookeeper 2181:2181 & zkCli.sh 127.0.0.1:2181
-
Kafka
helm install kafka bitnami/kafka --set zookeeper.enabled=false --set replicaCount=1 --set externalZookeeper.servers=zookeeper.vik.svc.cluster.local --set externalAccess.enabled=true --set externalAccess.service.type=LoadBalancer --set externalAccess.autoDiscovery.enabled=true --set rbac.create=true --set autoCreateTopicsEnable=true --set deleteTopicEnable=true -n vik # Kafka can be accessed by consumers via port 9092 on the following DNS name from within your cluster: # kafka.vik.svc.cluster.local # Each Kafka broker can be accessed by producers via port 9092 on the following DNS name(s) from within your cluster: # kafka-0.kafka-headless.vik.svc.cluster.local:9092 # Kafka Brokers port: 9094
-
Create Kafka topic
kubectl --namespace vik exec -it kafka-0 -- kafka-topics.sh --create --topic mytopic --replication-factor 1 --partitions 1 --bootstrap-server kafka.vik.svc.cluster.local:9092
helm install redis bitnami/redis --set auth.enabled=false -n vik
# create load balancer
kubectl expose service redis-master -n vik --port=6379 --target-port=6379 --name=redis-external --type=LoadBalancer
# Pull Zipkin image
docker pull openzipkin/zipkin
# Create Zipkin deployment in k8s
kubectl create deployment zipkin --image openzipkin/zipkin -n monitoring
# Create Zipkin service
kubectl expose deployment zipkin --type ClusterIP --port 9411 -n monitoring
# Create Zipkin load balancer
kubectl expose service zipkin -n monitoring --port=9411 --target-port=9411 --name=zipkin-external --type=LoadBalancer
# http://localhost:9411/zipkin/
# Pull Kafka-UI image
docker pull provectuslabs/kafka-ui
# Create Kafka-UI deployment in k8s
kubectl run kafka-ui --image provectuslabs/kafka-ui --env="KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka-0.kafka-headless.vik.svc.cluster.local:9093" --port=8080 -n vik
# Create Kafka-UI service
kubectl expose pod kafka-ui --type ClusterIP --port 8080 -n vik
# Create Kafka-UI load balancer
kubectl expose service kafka-ui -n vik --port=8080 --target-port=8080 --name=kafka-ui-external --type=LoadBalancer
# http://localhost:8080
git clone https://github.com/VikashChauhan51/quotes.git
# verify path
cd C:\quotes
# Execute on PowerShell in admin mode
openssl req -nodes -new -x509 -keyout ca.key -out ca.crt
# Execute on PowerShell in admin mode
Import-Certificate -FilePath C:\quotes\k8\certs\ca.crt -CertStoreLocation 'Cert:\LocalMachine\Root'
# Execute on PowerShell in admin mode
mkdir c:\mounted-k8
cd C:\quotes\k8\volume
kubectl apply -f .\local-persistent-volume.yaml -n vik
cd C:\quotes\k8\certs
kubectl create secret tls internal-ca-key-pair --cert=ca.crt --key=ca.key -n vik
kubectl apply -f .\issuer.yaml -n vik
kubectl create configmap trusted-root-ca-cert-configmap -- from-file=self-signed-ca.crt=ca.crt -n vik
# or
kubectl apply -f .\trusted-root-ca-cert-configmap.yaml -n vik
# Execute on PowerShell in admin mode
cd C:\quotes\local-k8\secrets
.\secrets.ps1
cd C:\quotes\charts
helm upgrade --install dapr-infra .\dapr-infra -n vik
# Navigate to **Quotes.API** folder path in terminal.
cd C:\quotes\backend\api\src\Quotes.API
dapr run --app-id="quotes-api" --app-port=5000 --dapr-grpc-port=53000 --dapr-http-port=53001 --components-path="C:\quotes\local-k8\dapr\components"
# Now, run QuotesAPI project with following launch setting:
"profiles": {
"QuotesAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DAPR_GRPC_PORT": "53000",
"DAPR_HTTP_PORT": "53001"
},
"applicationUrl": "https://localhost:7149;http://localhost:5201",
"dotnetRunMessages": true
}
# Now, call API with swagger endpoint
# or
dapr run --app-id="quotes-api" --app-port=5000 --dapr-grpc-port=53000 --dapr-http-port=53001 --components-path="C:\quotes\local-k8\dapr\components" dotnet run
cd C:\quotes\charts
helm upgrade --install quote-api .\quote-api -n vik
helm upgrade --install quote-identity .\quote-identity-app -n vik
helm upgrade --install quote-app .\quote-app -n vik
127.0.0.1 quote-api.dev
127.0.0.1 quote-identity.dev
127.0.0.1 quote-app.dev
Rewrite DNS name in CoreDNS config CoreDNS
- Add following entries into
coredns
COnfigMap ofKube-System
namespace. (belowready
text)
# rewrite name {url} {ingress-controller-service-name}.{ingress-service-namespace-name}.svc.cluster.local
rewrite name quote-identity.dev ingress-nginx-controller.ingress-nginx.svc.cluster.local
rewrite name quote-api.dev ingress-nginx-controller.ingress-nginx.svc.cluster.local
# Access following get url with `Accept:application/json` header
https://quote-api.dev/api/v1/root
# or
https://quote-api.dev/swagger/index.html
# Access identity server
https://quote-identity.dev/
# Access quote web app
https://quote-app.dev/