Cloud Native 10 min read

Automating Kubernetes‑Based .NET Core Microservices and CI/CD with Infrastructure as Code

This article details a hands‑on workshop that automates the provisioning of a Kubernetes‑based .NET Core microservice environment and CI/CD pipeline using infrastructure‑as‑code scripts, covering tool selection, script workflows, deployment steps, and initialization techniques for reproducible cloud‑native development.

Cloud Native Technology Community
Cloud Native Technology Community
Cloud Native Technology Community
Automating Kubernetes‑Based .NET Core Microservices and CI/CD with Infrastructure as Code

The workshop demonstrates how to automate the installation and configuration of a complete CI/CD and microservice deployment environment on a pre‑provisioned Kubernetes cluster using a series of Bash scripts, allowing participants to set up the entire stack with just a few commands.

It introduces the concept of Infrastructure as Code , emphasizing that not only application code but also the provisioning of servers, services, and their configuration should be described and version‑controlled as code.

Participants use the provided scripts to create a Git server (Gogs), CI/CD tools (Jenkins, Nexus, Sonarqube), and a container registry, then build, containerize, and deploy .NET Core services to Kubernetes, following a full end‑to‑end development workflow.

The overall architecture is illustrated with a diagram (refer to the original image) that shows the relationships between the Kubernetes cluster, CI/CD components, and microservices.

The complete source code and scripts are hosted on GitHub at https://github.com/netconf-cn2019-workshop/dev-services/ . The repository layout is as follows:

.
├── cicd-infra                 # CI/CD software deployment files
│   ├── cicd-installer.yaml    # Initialization config for CI/CD tools
│   ├── gogs.yaml              # Kubernetes config for Gogs
│   ├── jenkins.yaml           # Kubernetes config for Jenkins
│   ├── nexus.yaml             # Kubernetes config for Nexus
│   ├── sonarqube.yaml         # Kubernetes config for Sonarqube
│   └── vars                   # Variables used during installation
├── provision-cicd.sh          # Script to install CI/CD stack
├── provision-infra.sh         # Script to install shared microservice infrastructure
├── provision-services.sh      # Script to install individual microservices
├── service-infra              # Shared infrastructure deployment files
│   └── infra.yaml             # Kubernetes config for shared infra
├── services                   # Microservice deployment files
│   ├── service-list           # List of services and image tags
│   └── vars                   # Variables for service deployment
└── tmpl.sh                    # Template processor for variable substitution

The CI/CD installation is driven by provision-cicd.sh , which creates namespaces, deploys Jenkins, Nexus, Gogs, and Sonarqube, and runs an initializer script that waits for services to become ready and injects necessary data.

Variables such as deploy_suffix are defined in cicd-infra/vars and substituted into the YAML manifests by tmpl.sh before applying them with kubectl . Participants must edit the variable file to match their environment before running the scripts.

Microservice infrastructure (e.g., Redis, SQL Server) is installed via provision-infra.sh , which applies service-infra/infra.yaml to the appropriate namespace, waits for readiness, and then runs database initialization scripts.

Individual microservices are deployed with provision-services.sh . This script reads the service list from services/service-list , substitutes variables from services/vars , and applies each service’s k8s.yaml manifest.

Pre‑configuration steps are also automated: Jenkins pipelines are defined via configuration files, Gogs repositories are created through its REST API, Nexus passwords are set via its API, and SQL Server schema is initialized by executing commands inside the pod.

By describing every component—YAML manifests, Bash scripts, and variable files—as code, the workshop achieves a fully reproducible, version‑controlled, cloud‑native infrastructure that can be recreated reliably for future sessions.

ci/cdMicroservicesAutomationKubernetesInfrastructure as Code.NET Core
Cloud Native Technology Community
Written by

Cloud Native Technology Community

The Cloud Native Technology Community, part of the CNBPA Cloud Native Technology Practice Alliance, focuses on evangelizing cutting‑edge cloud‑native technologies and practical implementations. It shares in‑depth content, case studies, and event/meetup information on containers, Kubernetes, DevOps, Service Mesh, and other cloud‑native tech, along with updates from the CNBPA alliance.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.