Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Kubernetes [Jakub Kulhan] (6. sraz, Praha, 31.3.2016)

172 views

Published on

https://www.youtube.com/watch?v=3L4_xNw_ZE8&index=2&list=PLpPdQMJWIciFukX3rh8YOXxewyqX_4wkJ

Published in: Internet
  • Be the first to comment

  • Be the first to like this

Kubernetes [Jakub Kulhan] (6. sraz, Praha, 31.3.2016)

  1. 1. commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster 6. sraz přátel Symfony v Praze 31.3.2016
  2. 2. continuous integration … deployment … delivery
  3. 3. Kouzelná Almara 1 Java aplikace v Tomcatu (RESTful API + Wicket UI)
  4. 4. Tomcat…? hot deploy 🤘 PermGen 💩
  5. 5. fuck it! 🐙 #BitBucket => #Bamboo => SSH upload WARka => jetty-runner.jar + automatický reload po uploadu nového WARu (Node.JS skript)
  6. 6. Skrz 3 frontend PHP(-FPM) aplikace, 2 3 ReactPHP aplikace, ~30 RabbitMQ consumers, 1 Go aplikace
  7. 7. SVN 👹
  8. 8. fuck it! 🐙 #BitBucket => BB hook => checkout git do ~/commits/<commit> => hook.sh => (na stagingu automaticky) swap.sh
  9. 9. hitserver, adserver, ranking, RabbitMQ consumers supervisord 🤘 porty 💩
  10. 10. hitserver, adserver, ranking, RabbitMQ consumers supervisord 💩 porty 💩
  11. 11. Liftago 7 Java aplikací, 2 Node.JS aplikace, Python skripty v crontabu
  12. 12. 💩 Jelastic 💩 💩 Dogado 💩
  13. 13. fuck! fuck fuck! 🐙
  14. 14. ❓ Java/PHP/Go/Node/… ❓ Java 7 vs. 8, PHP 5.3 vs. 7.0, … ❓ supervisor/autorestart ❓ rolling deployment ❓ porty ❓ nezávislé na hostingu
  15. 15. ❓ Java/PHP/Go/Node/… ✅ Docker ❓ Java 7 vs. 8, PHP 5.3 vs. 7.0, … ✅ Docker ❓ supervisor/autorestart ✅ Kubernetes ❓ rolling deployment ✅ Kubernetes ❓ porty ✅ Kubernetes ❓ nezávislé na providerovi ✅ Kubernetes
  16. 16. Kubernetes
  17. 17. Pods Docker container billing:2016-03-31.345 Label app=billing Label env=prod Docker container logrotate:latest Volume /var/lib/invoices Volume /var/log 10.0.0.34 8080
  18. 18. Reconciliation loop Observed state Desired state
  19. 19. Reconciliation loop Observed state Desired statecreate
  20. 20. Reconciliation loop Observed state Desired statescale
  21. 21. Reconciliation loop Observed state Desired statehealth check
  22. 22. Replication controller Pod billing 10.0.0.34 Replication controller billing-prod app=billing env=prod replicas=3 app=billing env=prod Pod billing 10.0.0.35 app=billing env=prod Pod billing 10.0.0.36 app=billing env=prod
  23. 23. Replication controller Pod billing 10.0.0.34 Replication controller billing-prod app=billing env=prod replicas=1 app=billing env=prod
  24. 24. Service Pod billing 10.0.0.34 Replication controller billing-prod app=billing env=prod Pod billing 10.0.0.35 app=billing env=prod Pod api 10.0.0.14 app=api env=prod ??? ???
  25. 25. Service Pod billing 10.0.0.34 Replication controller billing-prod app=billing env=prod Pod api 10.0.0.14 app=api env=prod ??? !!!
  26. 26. Service Pod billing 10.0.0.34 Replication controller billing-prod app=billing env=prod Pod billing 10.0.0.35 app=billing env=prod Pod api 10.0.0.14 app=api env=prod Service billing-prod 10.1.0.1
  27. 27. Service Pod billing 10.0.0.34 Replication controller billing-prod app=billing env=prod Pod api 10.0.0.14 app=api env=prod Service billing-prod 10.1.0.1
  28. 28. Service Replication controller billing-prod Pod billing 10.0.0.66 app=billing env=prod Pod api 10.0.0.14 app=api env=prod Service billing-prod 10.1.0.1
  29. 29. …a více • Job (cron scheduler plánovaný na 1.3) • DaemonSet • Horizontal Pod Autoscaler • Secret • Ingress
  30. 30. $ kubectl create -f - <<EOF > apiVersion: v1 > kind: ReplicationController > metadata: > name: billing-prod > spec: > replicas: 3 > template: > metadata: > labels: > app: billing > env: prod > spec: > containers: > - name: billing > image: docker-registry.liftago.com/billing:latest > imagePullPolicy: Always …
  31. 31. … > env: > - name: SPRING_PROFILES_ACTIVE > value: prod > ports: > - containerPort: 8080 > livenessProbe: > httpGet: > path: /health > port: 8080 > initialDelaySeconds: 60 > timeoutSeconds: 5 > readinessProbe: > httpGet: > path: /health > port: 8080 > initialDelaySeconds: 1 > timeoutSeconds: 1 > imagePullSecrets: > - name: docker-repository.liftago.com > EOF
  32. 32. $ kubectl create -f <<EOF > apiVersion: v1 > kind: Service > metadata: > name: billing-prod > labels: > app: billing > env: prod > spec: > clusterIP: 10.1.0.1 > ports: > - port: 80 > targetPort: 8080 > protocol: TCP > selector: > app: billing > env: prod > EOF
  33. 33. $ kubectl get po -l app=billing,env=prod NAME READY STATUS RESTARTS AGE billing-prod-e3jcm 1/1 Running 0 1m billing-prod-4sdfb 1/1 Running 0 1m billing-prod-sd134 1/1 Running 0 1m $ kubectl get rc -l app=billing,env=prod NAME DESIRED CURRENT AGE billing-prod 3 3 1m $ kubectl get svc -l app=billing,env=prod NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE billing-prod 10.1.0.1 <none> 80/TCP 1m
  34. 34. $ kubectl exec -it billing-prod-e3jcm bash $ cat /etc/hosts 127.0.0.1 billing-prod-e3jcm …
  35. 35. kubernetes.io github.com/jakubkulhan/kube-jessie-ansible github.com/jakubkulhan/dockerfiles
  36. 36. A co ty commity/#GitHub/#CircleCI? 🤔
  37. 37. machine: java: version: oraclejdk8 environment: DOCKER_TAG: $(date +%Y-%m-%d).$CIRCLE_BUILD_NUM services: - docker post: - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS $DOCKER_REGISTRY dependencies: post: - sudo wget 'http://storage.googleapis.com/kubernetes-release/release/v1.2.0/bin/linux/amd64/kubectl' -O /usr/local/bin/kubectl - sudo chmod 755 /usr/local/bin/kubectl # docker pull suggested by https://discuss.circleci.com/t/caching-docker-image-with-docker-hub/1784 - docker pull $DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:latest || true test: … deployment: kubernetes: branch: master commands: - docker build -t $DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$DOCKER_TAG . - docker push $DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$DOCKER_TAG - docker tag -f $DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$DOCKER_TAG $DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:latest - docker push $DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:latest - > kubectl config set-cluster kubernetes --server=$KUBERNETES_MASTER && kubectl config set-credentials circleci --token=$KUBERNETES_TOKEN && kubectl config set-context kubernetes --cluster=kubernetes --user=circleci && kubectl config use-context kubernetes - kubectl rolling-update billing-prod --image=$DOCKER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$DOCKER_TAG --update-period=10s
  38. 38. Díky! Otázky? twitter.com/jakubkulhan medium.com/@jakubkulhan github.com/jakubkulhan

×