{"id":17983710,"url":"https://github.com/nishanil/ondotnet","last_synced_at":"2025-03-25T19:32:53.002Z","repository":{"id":54372645,"uuid":"319562550","full_name":"nishanil/ondotnet","owner":"nishanil","description":"Demos used in On.NET show","archived":false,"fork":false,"pushed_at":"2021-02-22T17:46:54.000Z","size":1114,"stargazers_count":26,"open_issues_count":3,"forks_count":17,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-20T17:41:55.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nishanil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-08T07:39:05.000Z","updated_at":"2023-04-09T16:01:26.000Z","dependencies_parsed_at":"2022-08-13T13:40:52.019Z","dependency_job_id":null,"html_url":"https://github.com/nishanil/ondotnet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanil%2Fondotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanil%2Fondotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanil%2Fondotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanil%2Fondotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nishanil","download_url":"https://codeload.github.com/nishanil/ondotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245530560,"owners_count":20630582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T18:18:08.776Z","updated_at":"2025-03-25T19:32:52.211Z","avatar_url":"https://github.com/nishanil.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ondotnet\nDemos used in On.NET show\n\nWatch https://youtu.be/zW4INO353Xg for details.\n\n\n## Running the sample locally\n\nNavigate to the `microservices` folder in a CLI. Then run the command `tye run`. If you're new to Tye, checkout the [getting started](https://github.com/dotnet/tye/blob/master/docs/getting_started.md) guide first.\n\n## Managing resiliency in code \n\nOpen [microservices/frontend/Startup.cs](https://github.com/nishanil/ondotnet/blob/main/microservices/frontend/Startup.cs) and uncomment the following code from the `ConfigureServices` method:\n\n```csharp\n// // uncomment the code below for handling partial failures in code\n//  .AddPolicyHandler(GetRetryPolicy())\n//  .AddPolicyHandler(GetCircuitBreakerPolicy());\n// \n```\nRun the sample again using `tye run`.\n\n\n## Managing resiliency using Service Mesh\n\nSamples covers both Linkerd and Istio configurations. The instructions are detailed out below.\n\n### Deploying dependencies\n\nFirst, deploy the application and its dependencies to Kubernetes before the services can be meshed.\n\u003cb\u003eRedis\u003c/b\u003e\n\nRun the following command from CLI:\n\n ```\n kubectl apply -f https://raw.githubusercontent.com/dotnet/tye/master/docs/tutorials/hello-tye/redis.yaml\n ```\n\n\u003cb\u003eZipkin\u003c/b\u003e\n\nRun the following command from CLI:\n\n ```\nkubectl apply -f https://raw.githubusercontent.com/dotnet/tye/master/docs/recipes/zipkin.yaml\n ```\n\nCheck the status using the command `kubectl get po`\n```\n➜  microservices git:(main) ✗ kubectl get po\nNAME                     READY   STATUS    RESTARTS   AGE\nredis-57455cbdbf-8czhg   1/1     Running   0          15s\nzipkin-6cf9b865d-h6s4v   1/1     Running   0          5s\n```\n\n ### Deploying application\n\n \u003eNote: Do not uncomment the code shown earlier. The resiliency will be handled in the service mesh.\n\nRun the following command from the CLI and provide your dockerhub/acr details for `Container Registry`. \n\n```\ntye deploy -i\n```\n\nYou'll be prompted for the connection string for redis. \n\n```\nValidating Secrets...\n    Enter the connection string to use for service 'redis':\n```\n\nEnter the following to use instance that you just deployed:\n\n```\nredis:6379\n```\n\n`tye deploy` will create kubernetes secret to store the connection string.\n\n```\nValidating Secrets...\n    Enter the connection string to use for service 'redis': redis:6379\n    Created secret 'binding-production-redis-secret'.\n```\nTye will prompt for the zipkin URI. If you've followed these basic instructions, then use `http://zipkin:9411`.\n    \n\nIf you're new to tye, checkout the guide [Getting started with Deployment](https://github.com/dotnet/tye/blob/master/docs/tutorials/hello-tye/01_deploy.md)\n\nCheck the status using the command `kubectl get po`\n\n```\n➜  microservices git:(main) ✗ kubectl get po\nNAME                       READY   STATUS    RESTARTS   AGE\nbackend-86b455fcc9-njj5p   2/2     Running   0          5m7s\nfrontend-df8546cb7-dg4xd   2/2     Running   0          5m7s\nredis-57455cbdbf-8czhg     1/1     Running   0          9m21s\nzipkin-6cf9b865d-h6s4v     1/1     Running   0          9m11s\n```\n\nTest the deployment using the following command:\n\n```\nkubectl port-forward svc/frontend 3000:80\n```\n\nOpen, [http://localhost:3000/](http://localhost:3000/) and checkout the page. Refresh a couple of times to see the error pop up randomly.\n\n ### Adding Service Mesh (Linkerd)\n\n Download and install the [Linkerd CLI](https://github.com/linkerd/linkerd2/releases/) from the release page and add it to the `PATH`.\n\n #### Validate your Kubernetes cluster\n\n ```\n linkerd check --pre\n ```\n On success, you should get a result like this:\n\n ```\n ➜  microservices git:(main) ✗ linkerd check --pre\nkubernetes-api\n--------------\n√ can initialize the client\n√ can query the Kubernetes API\n\nkubernetes-version\n------------------\n√ is running the minimum Kubernetes API version\n√ is running the minimum kubectl version\n\npre-kubernetes-setup\n--------------------\n√ control plane namespace does not already exist\n√ can create non-namespaced resources\n√ can create ServiceAccounts\n√ can create Services\n√ can create Deployments\n√ can create CronJobs\n√ can create ConfigMaps\n√ can create Secrets\n√ can read Secrets\n√ can read extension-apiserver-authentication configmap\n√ no clock skew detected\n\npre-kubernetes-capability\n-------------------------\n√ has NET_ADMIN capability\n√ has NET_RAW capability\n\nlinkerd-version\n---------------\n√ can determine the latest version\n‼ cli is up-to-date\n    is running version 20.12.1 but the latest edge version is 20.12.3\n    see https://linkerd.io/checks/#l5d-version-cli for hints\n\n ```\n\n #### Install Linkerd onto the Kubernetes cluster\n\nRun the following command to install Linkerd onto the cluster:\n\n```\nlinkerd install | kubectl apply -f -\n```\nand verify with the following command:\n\n```\nkubectl -n linkerd get deploy\n```\n\nYou'll see a response like this:\n\n```\n➜  microservices git:(main) ✗ kubectl -n linkerd get deploy\nNAME                     READY   UP-TO-DATE   AVAILABLE   AGE\nlinkerd-controller       1/1     1            1           2m48s\nlinkerd-destination      1/1     1            1           2m48s\nlinkerd-grafana          1/1     1            1           2m47s\nlinkerd-identity         1/1     1            1           2m48s\nlinkerd-prometheus       1/1     1            1           2m47s\nlinkerd-proxy-injector   1/1     1            1           2m47s\nlinkerd-sp-validator     1/1     1            1           2m47s\nlinkerd-tap              1/1     1            1           2m47s\n```\nRun the following command to see the linkerd dashboard\n\n```\nlinkerd dashboard \u0026\n```\n\n #### Add services to the Mesh\n\n Linkerd service mesh is an opt-in feature. You can configure the services that you like to add to the mesh. Since our services were deployed using `Tye`, we didn't have to work with Kubernetes deployment files. Hence we will use the following commands to extract the deployments and inject Linkerd annotations and redploy them onto the cluster.\n\nRun the following commands one by one:\n\n ```\nkubectl get deploy frontend -o yaml | linkerd inject - | kubectl apply -f -\n\nkubectl get deploy backend -o yaml | linkerd inject - | kubectl apply -f -\n\nkubectl get deploy zipkin -o yaml | linkerd inject - | kubectl apply -f -\n\nkubectl get deploy redis -o yaml | linkerd inject - | kubectl apply -f -\n ```\n\nNavigate to Linkerd Dashboard, and ensure the services are meshed.\n\n\n #### Configuring Resiliency\n\n Navigate to `servicemesh\\linkerd` folder and run the following command from the CLI:\n\n ```\n kubectl apply -f .\\backendServiceProfile.yaml\n ```\nForward port to your frontend service and navigate to the site to see the partial failures go away.\n\nIf you wish to use Istio instead of Linkerd, the following section will guide you install Istio as the service mesh and to configure resliency.\n\n ### Adding Service Mesh (Istio)\n\n Download and install the [istioctl](https://github.com/istio/istio/releases/) from the release page and add it to the `PATH`.\n\n #### Validate your Kubernetes cluster\n\n ```\n istioctl x precheck\n ```\n On success, you should get a result like this:\n\n```\n➜  Source istioctl x precheck\n\nChecking the cluster to make sure it is ready for Istio installation...\n\n#1. Kubernetes-api\n-----------------------\nCan initialize the Kubernetes client.\nCan query the Kubernetes API Server.\n\n#2. Kubernetes-version\n-----------------------\nIstio is compatible with Kubernetes: v1.18.8.\n\n#3. Istio-existence\n-----------------------\nIstio will be installed in the istio-system namespace.\n\n#4. Kubernetes-setup\n-----------------------\nCan create necessary Kubernetes configurations: Namespace,ClusterRole,ClusterRoleBinding,CustomResourceDefinition,Role,ServiceAccount,Service,Deployments,ConfigMap.\n\n#5. SideCar-Injector\n-----------------------\nThis Kubernetes cluster supports automatic sidecar injection. To enable automatic sidecar injection see https://istio.io/v1.8/docs/setup/additional-setup/sidecar-injection/#deploying-an-app\n\n-----------------------\nInstall Pre-Check passed! The cluster is ready for Istio installation.\n\n```\n #### Install Istio onto the Kubernetes cluster\nRun the following command to install Istio onto the cluster with `default` config profile:\n\n```\nistioctl install --set profile=default\n```\nOn success, you should get a result like this:\n```\n➜  Source istioctl install --set profile=default\nThis will install the Istio default profile with [\"Istio core\" \"Istiod\" \"Ingress gateways\"] components into the cluster. Proceed? (y/N) y\nDetected that your cluster does not support third party JWT authentication. Falling back to less secure first party JWT. See https://istio.io/v1.8/docs/ops/best-practices/security/#configure-third-party-service-account-tokens for details.\n✔ Istio core installed\n✔ Istiod installed\n✔ Ingress gateways installed\n✔ Installation complete\n```\nMore about Installation Configure Profiles, check the [documentation](https://istio.io/latest/docs/setup/additional-setup/config-profiles/)\n\nCheck the installation status with the following command:\n\n```\nkubectl -n istio-system get pods\n```\nResulting to:\n```\n➜  Source kubectl -n istio-system get pods\nNAME                                    READY   STATUS    RESTARTS   AGE\nistio-ingressgateway-77bcf54747-24nvh   1/1     Running   0          3m22s\nistiod-66bcf5d94f-s22s7                 1/1     Running   0          3m40s\n```\n#### Add services to the Mesh\n\nYou can configure the services that you like to add to the mesh. Since our services were deployed using `Tye`, we didn't have to work with Kubernetes deployment files. Hence we will use the following commands to extract the deployments and inject Istio annotations and redploy them onto the cluster.\n\nRun the following commands one by one:\n\n ```\nkubectl get deploy backend -o yaml | istioctl kube-inject -f - | kubectl apply -f -\nkubectl get deploy frontend -o yaml | istioctl kube-inject -f - | kubectl apply -f -\nkubectl get deploy redis -o yaml | istioctl kube-inject -f - | kubectl apply -f -\nkubectl get deploy zipkin -o yaml | istioctl kube-inject -f - | kubectl apply -f -\n ```\n\n#### Configuring Resiliency\n\n Navigate to `servicemesh\\istio` folder and run the following command from the CLI:\n\n ```\n kubectl apply -f .\\backendVirtualService.yaml\n ```\n \nTo install a `Kiali` dashboard, along with `Prometheus`, `Grafana`, and `Jaeger`, run the following commands:\n\n```\nkubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.8/samples/addons/prometheus.yaml\n\nkubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.8/samples/addons/grafana.yaml\n\nkubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.8/samples/addons/jaeger.yaml\n\nkubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.8/samples/addons/kiali.yaml\n```\nTo run the dashboard, run these commands:\n\n```\nkubectl rollout status deployment/kiali -n istio-system\n\nistioctl dashboard kiali\n```\nForward port to your frontend service and navigate to the site to see the partial failures go away.\n\nThat's it!\n\n [@nishanil](https://twitter.com/nishanil)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnishanil%2Fondotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnishanil%2Fondotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnishanil%2Fondotnet/lists"}