• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    HTML
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Demoing deployment of Docker containers into Kubernetes for both minikube and Azure AKS.

Docker Image CI

ProductsStore on Kubernetes

This is a sample application used to demonstrate how to create dockerized apps and deploy them to Kubernetes cluster.

It takes a sample ASP.NET Core MVC app, creates its Dockerfile, then the Kubernetes deployment objects.

The Dockerfile is used to build the app from source code. Then runs the app inside a docker container.
The k8s objects defined in YAML files are used to deploy the app into a Kubernetes cluster. These files are:

  1. mvc-deployment.yaml: used to create a Deployment and a Service to run the app.
  2. mssql-deployment.yaml: used to create a Deployment and a Service to run the SQL Server container.
  3. mssql-config-map.yaml: creates a ConfigMap object to store the database connection string as key-value pair. It is accessed by the app to retrieve the connection string as apass it as environment variable.
  4. mssql-secret.yaml: creates a Secret to securely save database connection string as key-value pair.
  5. mssql-pv.azure.yaml: creates PersistentVolume and PersistentVolumeClaim objects in order to provision a storage space to save the database files.

1) Introduction: Kubernetes and microservices

1.1) The vision: Microservices on Docker containers on Kubernetes hosted on the Cloud and powered by DevOps.

Source: https://blog.nebrass.fr/playing-with-spring-boot-on-kubernetes/
1.2) Learn more about Kubernetes architecture:
1.3) Learn more about Kubernetes objects: Deployment, Service, ConfigMap, Secret, PersistentVolume...

2) Create docker container

Inside the MvcApp folder, we have a sample ASP.NET Core MVC application that displays web pages and connects to a Database. The goal here is to run this application in a Docker container. For that, we need the Dockerfile which describes the instructions to build/compile app from source code and deploy it into a base image that have .NET Core SDK and Runtime.

2.0) Install Docker into your machine Make sure you have Docker installed and running in your machine: Docker Desktop

2.1) Start Docker in your machine and check if it runs successfully by deploying a sample image called hello-world:

$ docker run hello-world  
  Hello from Docker!  
  This message shows that your installation appears to be working correctly.    
2.2) Create Docker image  
$ cd MvcApp  
$ docker build .     # don't forget the dot at the end to configure thecontext!  
$ docker build --rm -f "Dockerfile" -t mvc-app:1.0 .   
2.3) List the created image  
$ docker images  
2.4) Run the created image  
$ docker run --rm -d -p 5555:80/tcp mvc-app:1.0   
2.5) List the running image  
$ docker ps  
2.6) Open browser on localhost:5555 and note how the app doesn't connect to database despite it is configured to!!  
2.7) Configure and start SQL Server on container  
$ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=@Aa123456' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-16.04  

3) Run the App using docker-compose

When dealing with multiple containers, Docker Compose becomes really useful. It allows to define the configuration in a single file. This file then will be used to build, deploy and stop all the images using docker-compose CLI. Open the docker-compose.yaml file. Note how we are defining 2 services: one to run the web app and a second one to deploy the database.

3.1) Build the Docker Compose file to create the images  
$ docker-compose build  
3.2) Run the Docker Compose file to run the created images  
$ docker-compose up  
  Starting sqldb-k8s     ... done  
  Starting mvcapp-k8s    ... done  

4) Push containers to Docker Hub

Now that we have created the docker image in our machine, we want to deploy it into Kubernetes. But, Kubernetes should get that image through a Container Registry. Container Registry is a like a database for all our containers. We can use Azure ACR or Docker Hub... We'll continue with Docker Hub. Make sure you create a an account here hub.docker.com and take note of your Docker Hub ID (Registry name).

4.1) Create a variable to hold our Registry name  
$ $registry="REPLACE_WITH_YOUR_DOCKER_HUB_ID"  
4.2) Tag the image by appending the registry name  
$ docker tag mvc-app:1.0 $registry/mvc-app:1.0  
4.3) Login to Docker Hub and enter your login and password    
$ docker login  
4.4) Push the image into the registry  
$ docker push $registry/mvc-app:1.0  
4.5) Check your hub.docker.io, you should see the image uploaded into a repository

5) Deploy to Minikube/Kubernetes using the Dashboard

5.1) Start the Dashboard  
5.2) $ minikube start  
5.3) $ minikube dashboard  

6) Deploy to Kubernetes using Kubectl CLI

6.1) $ Kubectl run …  
6.2) $ kubectl get deployments  
6.3) $ kubectl get secrets  
6.4) $ kubectl get services  

7) Deploy to Kubernetes using configuration YAML files

7.1) $ kubectl apply -f mssql-secret.yaml  
     $ kubectl get secrets   
7.2) $ kubectl apply -f mssql-pv.azure.yaml  
     $ kubectl get pv  
7.3) $ kubectl apply -f mssql-deployment.yaml  
     $ kubectl get deployments  
7.4  $ kubectl apply -f mvc-deployment.azure.yaml  
     $ kubectl get deployments  
7.5) $ minikube config set memory 4096  # if we need to resize minikube  
7.6) $ kubectl delete services,deployments,pvc,secrets --all -n default

8) Create managed Kubernetes cluster in Azure using AKS

8.1) $ az group create \  
		  --location westeurope \  
		  --subscription "Microsoft Azure Sponsorship" \  
		  --name aks-k8s-rg  
8.2) $ az aks create \  
		  --generate-ssh-keys \  
		  --subscription "Microsoft Azure Sponsorship" \  
		  --node-count 1 \  
		  --resource-group aks-k8s-rg \  
		  --name aks-k8s   
8.3) $ az aks get-credentials \  
		  --resource-group aks-k8s-rg \  
		  --name aks-k8s \  
		  --subscription "Microsoft Azure Sponsorship" 
	 Merged "aks-k8s" as current context in /Users/houssem/.kube/config  
8.4) $ kubectl create clusterrolebinding kubernetes-dashboard \  
               --clusterrole=cluster-admin \  
               --serviceaccount=kube-system:kubernetes-dashboard  
8.5) $ az aks browse \
		  --resource-group aks-k8s-rg \
		  --name aks-k8s \
		  --subscription "Microsoft Azure Sponsorship"  

9) Create the CI/CD pipelines for using Azure DevOps

9.1) CI pipeline: builds the container and pushes it to docker hub.  

9.2) CD pipeline: deploys the YAML manifest files into Kubernetes cluster.  

10) Discussion points

scalability, health check, mounting volume, resource limits, service discovery, deploy with Helm...

11) More resources

eShopOnContainers: https://github.com/dotnet-architecture/eShopOnContainers

https://www.udemy.com/kubernetes-for-developers/ Please email me if you want a free coupon :)

More Repositories

1

terraform-course

Full course for deploying Infrastructure to the Cloud using Terraform
HCL
293
star
2

aks-course

Demoing Kubernetes/AKS features
HCL
150
star
3

WebAppWithDatabaseDemo

Sample ASP.NET Core MVC app with database for demoing CI-CD pipelines using Azure DevOps
HTML
107
star
4

AzureDevOpsPipelines-Templates

This project shows how to use YAML templates in Azure DevOps Pipelines.
HCL
67
star
5

CheapIdeas

Sample app that shows how to do Authentication/Authorisation with ASP.NET Web API Identity and Xamarin.
C#
67
star
6

kubernetes-ingress-tls-ssl-https

Demoing configuration for Ingress and HTTPS/TLS/SSL in Kubernetes.
50
star
7

angular-app-kubernetes

Sample Dockerised angular app deployed on Kubernetes on Azure using AKS
TypeScript
48
star
8

github-actions-course

Samples for Github Actions DevOps pipelines and workflows
CSS
45
star
9

azure-bicep-course

Sample demo for CI/CD for Azure Bicep
Bicep
42
star
10

Facebook-Login-Xamarin-Forms

Demo for login to Facebook API from Xamarin Forms
C#
39
star
11

social-media-templates

Provides templates for using Twitter, Youtube, Instagram, Flickr, Foursquare and Eventbrite API with Xamarin Forms.
C#
32
star
12

aca-course

Repository with templates and code showing how to work with Azure Container Apps (ACA)
HCL
29
star
13

aks-keyvault

Access Azure Key Vault secrets, keys and certs from AKS Pods using Secret Store CSI provider and Pod Identity.
PowerShell
28
star
14

EFCore-SQLite-XamarinForms

Sample app for using Entity Framework Core 2.0 on .NET Standard with SQLite for Xamarin Forms.
C#
25
star
15

Trigger-Pipeline-From-Another-Pipeline

Triggering a pipeline from another one in Azure DevOps.
25
star
16

Xamarin-Forms-Pie-Chart

Enrich your mobile application with Pie Charts.
C#
25
star
17

SeleniumTestsOnDocker

Demo app for running Selenium UI tests in Docker containers
C#
25
star
18

Google-Login-Xamarin-Forms

Login with Google API from Xamarin.Android app
C#
23
star
19

AzureDevOpsPipelines-Tips

This demo shows how to deploy infrastructure into Azure using Terraform and Azure DevOps Yaml pipelines.
HCL
22
star
20

BottomBar-Xamarin-Forms

Sample Xamarin Forms app showing Bottom NavBar for Android
C#
21
star
21

ExpandableListView

Show how to expand ListView items in Xamarin Forms
C#
21
star
22

Xamarin-Forms-Popup-Demo

Sample Xamarin Forms app for using Popups
C#
20
star
23

UploadFileToServer

Upload a file from Xamarin Forms app to ASP.NET web application.
JavaScript
19
star
24

EFK-Kubernetes

A demo for installing EFK suite into Kubernetes
19
star
25

MicroservicesOnContainers

Microservice application deployed on Docker containers on Kubernetes
C#
18
star
26

aks-enterprise

Terraform template for creating an AKS cluster with Application Gateway.
HCL
18
star
27

rbac-kubernetes-minikube

Create users with assigned roles in Kubernetes
18
star
28

build-agents-in-containers

Demo for running Azure Pipelines inside Docker Containers in a host machine or in Kubernetes/AKS with KEDA to support horizontal scalability.
Shell
16
star
29

Terraform-Demo

Using Terraform to create web app and SQL Server database in Azure cloud.
HCL
16
star
30

azure-devops-pipelines-samples

Demoing how to use Matrix and Each definitions in Azure DevOps YAML pipelines.
C#
14
star
31

stages-jobs-tasks

Demoing stages, jobs and tasks in Azure DevOps yaml pipelines.
14
star
32

IoC-DI-Xamarin-Forms

Sample app for demoing IoC/DI using Unity in Xamarin Forms
C#
14
star
33

WebAppMonitoring

Sample project for using Prometheus and Grafana to monitor an ASP.NET Core app running in Kubernetes
C#
13
star
34

powershell-autocomplete

Configures powershell to auto-complete commands based on the history
13
star
35

SqlServer-Database

Sample SQL Server database project for CI/CD in Azure DevOps
13
star
36

rbac-aks-aad

Workshop for using Azure AD with AKS cluster to authenticate and authorise users.
Shell
13
star
37

Xamarin-Forms-Maps-Sample

Provides a sample code using Xamarin.Forms.Maps.
C#
13
star
38

azure-network-course

Course for learning Azure Hub and Spoke implementation
HCL
13
star
39

azure-pipelines-secrets-key-vault

Demoing how to use Azure Key Vault Secrets from within Azure DevOps Pipelines.
13
star
40

NetworkPolicy-Calico

This workshop shows how to create Network Policies for Pods in Kubernetes.
Shell
12
star
41

ResilientHttpClient

Sample app using Polly for retying Http requests
C#
12
star
42

private-aks

HCL
11
star
43

Xamarin-Forms-Template

Sample Xamarin Forms template
C#
11
star
44

aks-file-share

Sample demo for creating an Azure File Share using AKS.
Shell
11
star
45

mcp-certification-483

Sample codes for MCP 483 (Programming in C#)
C#
10
star
46

Xamarin.Auth

Login to Twitter, Facebook and LinkedIn and get user profile information
C#
10
star
47

Infinite-Scroll-Xamarin-Forms-Demo

Infinite Scroll sample demo for Xamarin Forms
C#
10
star
48

CustomEntryRenderer-XamarinForms

Sample code for custom rounded entry implemented using Custom Renderer for Xamarin Forms.
C#
10
star
49

ASP.NET-Identity

Authentication and authorisation in ASP.NET Identity with user/role management.
C#
10
star
50

azure-spn

Demoing Azure Service Principal (SPN) with RBAC.
9
star
51

CrossVideoPlayer

Cross video player element for Xamarin Forms.
C#
9
star
52

Xamarin-Forms-RepeaterView

Sample implementation for Repeater for Xamarin Forms
C#
9
star
53

azure-acr

Demoing Azure Container Registry (ACR) capabilities.
C#
9
star
54

houssemdellai.github.io

https://houssemdellai.github.io/
PowerShell
9
star
55

k8s-scalability

Workshop for Kubernetes/AKS scalability options: HPA, Cluster Autoscaler and Virtual Node
PowerShell
9
star
56

Azure-Push-Notification-For-Xamarin

This plugin makes it easy to register to Microsoft Azure Push Notifications from a Xamarin.Forms project and supports using Tags.
C#
9
star
57

AspNetCore-Docker

ASP.NET Core app used for demoing CI/CD and Docker in Udemy course: https://www.udemy.com/course/devops-using-vsts-docker-azure
HTML
8
star
58

FFImageLoading-XamarinForms-Demo

Demo on using FFImageLoading with Xamarin Forms
C#
8
star
59

az-pipelines-cli-demo

Demoing $ az pipelines CLI commands for Azure DevOps Services
8
star
60

datadog-prometheus-k8s

Collecting (Prometheus) metrics metrics using Datadog in Kubernetes.
HTML
8
star
61

demo-angular-app

Sample empty angular app with Dockerfile
TypeScript
8
star
62

AzureResourceGroup-WebApp-SQL

Sample for demoing CI/CD for an ARM template using Azure DevOps
PowerShell
7
star
63

TodoApp-Udemy

The demo app used in My course on Udemy https://www.udemy.com/i-want-to-connect-my-xamarin-forms-app-to-rest-api/
C#
7
star
64

terraform-azapi-appservice-domain

Uses Azure App Service Domain to create Custom Domain Names in Azure
HCL
7
star
65

kubernetes-allowed-registries-policy

Demoing whitelisting Container Registries in Kubernetes using OPA/Gatekeeper policy.
6
star
66

XamarinForms-MVVM-Navigation

Implementing NavigationService for Xamarin Forms & MVVM apps
C#
6
star
67

terraform-iac

Sample terraform templates for demoing IaC with Azure.
HCL
5
star
68

MyLibrary.Nuget

Sample .NET Core library to demonstrate CI/CD pipelines for nuget packages using Azure DevOps.
C#
5
star
69

kubernetes-backup-velero

Create Kubernetes backups (YAML, Volumes) using Velero.
5
star
70

Terraform-GCP

Provisioning a compute engine on GCP using Terraform
HCL
5
star
71

eck-fluentd-operators-kubernetes

Demo for installing ECK/Elasticsearch cluster, Kibana and Fluentd using Kubernetes operators.
5
star
72

XamarinForms-LocalRepository

Xamarin.Forms project that shows an easy solution to store data using files instead of dealing with complicated Database. It stores JSON text into a file.
C#
5
star
73

Windows10-HttpClient

A sample project template that shows how to consume Web API web services (GET, POST, PUT and DELETE) using Windows 10 platform.
C#
4
star
74

k8s-opa-gatekeeper-demo

Demoing OPA Gatekeeper Policies with Kubernetes
PowerShell
4
star
75

kubernetes-ci-cd-pipelines

C#
4
star
76

AspNetCore-PR

Sample project for demoing PR validation in Azure DevOps
C#
4
star
77

HockeyApp-XamarinForms

App that shows how to integrate HockeyApp into Xamarin Forms
C#
4
star
78

AdMobView-XamarinForms

Implementing Google AdMob for Xamarin.Forms.
C#
4
star
79

Video-Player-Xamarin

A sample app for demoing playing a video on Xamarin Forms apps
C#
4
star
80

Xamarin-Forms-Training

Sample codes that shows how to use Xamarin Forms
C#
4
star
81

PerfectBody-DevOps

Sample Xamarin Forms app for demoing DevOps with VSTS and VS Mobile Center.
C#
4
star
82

kubeLinter-k8s

Smarty
4
star
83

MyShuttle-Java-app

Java
3
star
84

azure-managed-identity

Demoing Azure Managed Identity with RBAC model for Azure DevOps
3
star
85

DatabaseMigrations-CI-CD

Sample ASP.NET Core MVC app to demo CI/CD for Database using EF Core Migrations
HTML
3
star
86

Signature-Pad-Xamarin-Forms

A demo for using SignaturePad (https://github.com/xamarin/SignaturePad) nuget library with Xamarin Forms to create signature.
C#
3
star
87

Employees-Directory-Aspnet-Mvc

Associate a Department entity with an Employee in the ASP.NET MVC generated views.
C#
3
star
88

webapp-demo

Demo for ASP.NET 5.0 app that connects to Database and to Azure Application Insights.
C#
3
star
89

aks-appgw-aad

Terraform template for creating an AKS cluster with Application Gateway into existing Spoke VNET.
HCL
3
star
90

Ansible-Azure-Demo

3
star
91

MCP-483-Codes

Sample codes for MCP 483 exam certification.
C#
3
star
92

azure-course

Getting started with Azure cloud
PowerShell
3
star
93

aks-acr-identity-keyvault

HCL
3
star
94

Microsoft-Cognitive-Services-API

Provides sample code and nuget packages to use Microsoft Cognitive Services API.
C#
2
star
95

WPF-Demo

Sample WPF application with unit and UI tests (Selenium)
C#
2
star
96

aks-nodepool-demo

Demoing how to use AKS Nodepools
Shell
2
star
97

Xamarin-Forms-IoC

Sample Xamarin Forms app with IOC/DI using Unity container
C#
2
star
98

WebAppAndDbForK8s

Sample ASP.NET Core app with SQL Server used for demoing Azure Kubernetes Services (AKS), CI-CD and DevOps with VSTS
C#
2
star
99

AutomobileTnCrossPlatforms

Shows Xamarin.Forms UI capabilities.
Java
2
star
100

kubernetes-operators-demo

Demoing how to install Operators in Kubernetes.
2
star