Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python, Kubernetes & friends
Search
Alexandre González
May 13, 2016
Technology
0
460
Python, Kubernetes & friends
This is the presentation I made for PyGrunn 2016.
Thanks to Jobandtalent for sponsoring my trip! :)
Alexandre González
May 13, 2016
Tweet
Share
More Decks by Alexandre González
See All by Alexandre González
Building an Enterprise-Ready Lambda Experience
agonzalezro
0
86
Fragmentación, el virus que puede acabar con tu alta disponibilidad (con ejemplos para kubernetes)
agonzalezro
0
410
From source code to Kubernetes, a Continuous Deployment tale
agonzalezro
0
100
From pets to cattle, the way of Kubernetes
agonzalezro
2
600
Kubernetes 101
agonzalezro
0
630
Custom Volume Plugins
agonzalezro
1
1.3k
Docker 101
agonzalezro
4
200
Go 101 updated
agonzalezro
0
780
Kubernetes Volume Plugins: Flocker
agonzalezro
2
760
Other Decks in Technology
See All in Technology
Goでマークダウンの独自記法を実装する
lag129
0
210
Browser
recruitengineers
PRO
3
260
モバイルアプリ研修
recruitengineers
PRO
2
220
Understanding Go GC #coefl_go_jp
bengo4com
0
1.1k
JavaScript 研修
recruitengineers
PRO
2
130
マイクロモビリティシェアサービスを支える プラットフォームアーキテクチャ
grimoh
1
200
mruby(PicoRuby)で ファミコン音楽を奏でる
kishima
1
220
TypeScript入門
recruitengineers
PRO
6
1.2k
Amazon Bedrock AgentCore でプロモーション用動画生成エージェントを開発する
nasuvitz
6
420
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
2
20k
DeNA での思い出 / Memories at DeNA
orgachem
PRO
3
1.5k
RAID6 を楔形文字で組んで現代人を怖がらせましょう(実装編)
mimifuwa
0
300
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Statistics for Hackers
jakevdp
799
220k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Side Projects
sachag
455
43k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Transcript
PYTHON, Kubernetes & FRIENDS @AGONZALEZRO
WHAT IS Kubernetes?
Framework for building distributed systems. (Kelsey's dixit)
None
OUR FIRST APP! $ kubectl run pygrunn \ --image=python:2.7 \
--command -- python -m SimpleHTTPServer
WHAT DO WE GET HERE?
A POD $ kubectl get pods NAME READY STATUS RESTARTS
AGE pygrunn-1906403705-dckh7 1/1 Running 0 1m
A REPLICA SET $ kubectl get replicasets NAME DESIRED CURRENT
AGE pygrunn-1552838933 1 1 11s
AND A DEPLOYMENT $ kubectl get deployments NAME DESIRED CURRENT
UP-TO-DATE AVAILABLE AGE pygrunn 1 1 1 1 2m
SHOW IT TO THE WORLD $ kubectl expose deployment pygrunn
\ --port=80 --target-port=8000 --type=LoadBalancer
LET'S USE THE WAITING TIME $ kubectl exec -it pygrunn-1906403705-dckh7
bash
HERE IT IS $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP
PORT(S) AGE pygrunn 10.3.255.124 130.211.52.23 80/TCP 57s
HN FRONT PAGE! $ kubectl scale deployment pygrunn --replicas=3
THE END (FOR NOW)
None
WHAT WE DID THERE? ▸ Pods ▸ Replica Set ▸
Service ▸ Deployment
A "REAL" DEPLOYMENT
MAIN.PY from flask import Flask, url_for app = Flask(__name__) @app.route('/')
def index(): return '<img width="100%" src="{}" />'.format( url_for('static', filename='grumpy.gif') ) if __name__ == '__main__': app.run(host='0.0.0.0')
DOCKERFILE FROM python:2.7.11-onbuild EXPOSE 5000 CMD ["uwsgi", "-http 5000", "-w
main"]
$ docker build -t agonzalezro/pygrunn:grumpy . $ docker push agonzalezro/pygrunn
DEPLOYMENT.YAML (1/3) apiVersion: extensions/v1beta1 kind: Deployment metadata: name: pygrunn-deploy labels:
name: pygrunn-deploy ...
DEPLOYMENT.YAML (2/3) ... spec: replicas: 3 selector: matchLabels: name: flask-app
template: metadata: labels: name: flask-app ...
DEPLOYMENT.YAML (3/3) ... spec: containers: - name: app image: agonzalezro/pygrunn:grumpy
ports: - containerPort: 5000 - name: nginx image: agonzalezro/pygrunn-nginx ports: - containerPort: 80 readinessProbe: httpGet: path: / port: 80
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: pygrunn-deploy labels: name: pygrunn-deploy
spec: replicas: 3 selector: matchLabels: name: flask-app template: metadata: labels: name: flask-app spec: containers: - name: app image: agonzalezro/pygrunn:happy ports: - containerPort: 5000 - name: nginx image: agonzalezro/pygrunn-nginx ports: - containerPort: 80 readinessProbe: httpGet: path: / port: 80
SERVICE.YAML apiVersion: v1 kind: Service metadata: name: flask-service spec: type:
LoadBalancer ports: - port: 80 targetPort: 5000 selector: name: flask-app
$ kubectl create -f deployment.yaml -f service.yaml
$ sed -i "s/replicas: 3/replicas: 5/" deployment.yaml $ kubectl apply
-f deployment.yaml
$ sed -i "s/grumpy/happy/" deployment.yaml $ kubectl apply -f deployment.yaml
HOMEWORK ▸ Add a nginx in top ▸ Add a
DB ▸ Use a private registry
THE END (AGAIN)
None
None
None
Thanks! @AGONZALEZRO