DotNetDay18: VSTS Release Pipelines with Kubernetes by Marc Müller

DotNetDay18: VSTS Release Pipelines with Kubernetes by Marc Müller

Nowadays, everybody is talking about Docker and Microservices. But how does that affect me as a developer working with the Microsoft stack? In this session Marc shows how to build an automated release pipeline using Visual Studio and VSTS which deploys ASP.NET Core Microservices into a Kubernetes infrastructure. In addition to the full developer stack needed to build the pipeline, the session covers advanced topics, such as staging environments and load-balancing.

Original Link:
https://www.slideshare.net/MarcMller/vsts-release-pipelines-with-kubernetes

E6cffbf3b7a5fbfee4707033ef1636f5?s=128

dotnetday

May 29, 2018
Tweet

Transcript

  1. None
  2. Marc Müller Principal Consultant @muellermarc

  3. ▪ ▪ ▪ ▪

  4. None
  5. https://twitter.com/dberkholz/status/689211852157407233

  6. Write Code Customer use the code Write Code Customer use

    the code
  7. 100 deployments per day!

  8. ▪ ▪ ▪ ▪ ▪ ▪

  9. None
  10. None
  11. ▪ Versioned artifact ▪ Isolated deployable unit ▪ Container image

    is bit by bit identical when deployed ▪ Abstraction of data center resources ▪ ▪ Orchestration is “Cattle Business” ▪ ▪
  12. None
  13. Server Host OS Hypervisor Server Host OS Docker Engine Guest

    OS Guest OS Guest OS Bins/Libs Bins/Libs App A App A’ App B Bins/Libs Bins/Libs App A App A’ App B App B’ App B App B’ App B App B’ Containers are isolated, but share OS and, where appropriate, bins/libraries Bins/Libs Image Source: https://sec.ch9.ms/sessions/build/2016/B822.pptx
  14. ▪ ▪

  15. None
  16. Developer PC / Laptop Docker Engine Container Container Container

  17. FROM microsoft/aspnetcore:2.0 WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet",

    "a.dll"] FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 FROM microsoft/aspnetcore-build:2.0 AS build WORKDIR /src COPY *.sln ./ COPY SampleWebApplication/SampleWebApplication.csproj SampleWebApplication/ RUN dotnet restore COPY . . WORKDIR /src/SampleWebApplication RUN dotnet build -c Release -o /app FROM build AS publish RUN dotnet publish -c Release -o /app FROM base AS final WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet", "SampleWebApplication.dll"]
  18. None
  19. App1 App2

  20. VSTS Build VSTS Release Management Docker Registry Build App Test

    Build Container Repo Container Info Publish to Target Host Container Info Push Host Pull Config Artifact
  21. ▪ ▪ ▪ ▪ ▪ ▪ ▪

  22. ▪ ▪ ▪ ▪

  23. None
  24. ▪ ▪ Pod Container Pod Container Container 10.0.10.14 10.0.10.16 localhost

    Multi container Pods should only be used for highly coupled containers! Pod Container 10.0.10.15
  25. ▪ ▪ Replication Controller / Deployment (Replication Set) Pod Container

    Pod Container Pod Container
  26. ▪ ▪ ▪

  27. ▪ ▪ ▪ ▪ ▪ ▪ Service Pod Container Pod

    Container Pod Container A 1.2 A 1.2 A 1.2 A 1.2
  28. ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

  29. None
  30. None
  31. ▪ ▪ ▪ ▪ ▪ ▪ Source: https://helm.sh/

  32. Source: https://docs.helm.sh/developing_charts/#charts

  33. None
  34. None
  35. None
  36. None
  37. Image Source: https://docs.docker.com/registry/spec/api/

  38. ▪ ▪ ▪ ▪ ▪ ▪

  39. None
  40. None
  41. VSTS Azure Resource Group DCOS Master DCOS Master Master Agent

    VSTS Agent App1 App1 App1 App1 App1 App2 Git Build Release Internet Azure Load Balancer Ingress LeGo
  42. https://docs.microsoft.com/en-us/azure/container-service/kubernetes/container-service-intro-kubernetes

  43. ### setup the cli settings kubectl config unset contexts.AKSDevFunDemo az

    account set --subscription $subscriptionname az account show # ...Register providers... ### setup kubernetes cluster az group create -n "$ressourcegroup" -l "westeurope" az aks create --resource-group $ressourcegroup --name $clustername --node-vm-size Standard_DS1_v2 --node-count 1 --generate- ssh-keys az aks get-credentials --resource-group $ressourcegroup --name $clustername az acr create --name $containerregistry --resource-group $ressourcegroup --sku Basic az acr update -n $containerregistry --admin-enabled true $acrusername = az acr credential show -n $containerregistry --query username $acrpassword = az acr credential show -n $containerregistry --query passwords[0].value ### deploy kubernetes configurations kubectl apply -f .\namespaces.yaml $dockerserver = "$($containerregistry).azurecr.io" kubectl create secret docker-registry acrauth $containerregistry --docker-username=$acrusername --docker- password=$acrpassword --docker-server="$dockerserver" --docker-email="$email" --namespace dev # ...add secrets for every namespace... helm init --upgrade --service-account default helm repo update helm install stable/nginx-ingress --namespace kube-system --set rbac.create=false --set rbac.createRole=false --set rbac.createClusterRole=false helm install stable/kube-lego --set config.LEGO_EMAIL=$email --set config.LEGO_URL=https://acme- v01.api.letsencrypt.org/directory
  44. None
  45. None
  46. ▪ ▪ ▪ ▪ ▪ ▪

  47. None
  48. ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

  49. VSTS Build Agent Build Pool Build Pool Build Pool Build

    Definition Build Definition Build Queue Docker Engine Build Agent
  50. None
  51. None
  52. None
  53. ▪ ▪ ▪ ▪ ▪

  54. None
  55. None
  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. None
  71. None
  72. ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪

    ▪ ▪
  73. None
  74. None
  75. We are looking for great talents to join our team!

    Apply to job@4tecture.ch www.4tecture.ch/jobs
  76. None
  77. None
  78. None