Hoy planeo contarte cĂłmo escribir aplicaciones y cuĂĄles son los requisitos para que tu aplicaciĂłn funcione bien en Kubernetes. Para que no haya dolor de cabeza con la aplicaciĂłn, para que no tenga que inventar y construir algĂșn tipo de "muletas" a su alrededor, y todo funcionĂł segĂșn lo previsto por Kubernetes.
Esta conferencia es parte de Slurm Night School en Kubernetes . Puede ver las conferencias teĂłricas abiertas de la Escuela vespertina en Youtube, agrupadas en una lista de reproducciĂłn . Para aquellos que se sienten mĂĄs cĂłmodos con el texto que con el video, hemos preparado este artĂculo.
Mi nombre es Pavel Selivanov, en este momento soy el ingeniero lĂder de DevOps en Mail.ru Cloud Solutions, creamos "nubes", gestionamos kubernetis, etc. Mis tareas ahora incluyen ayudar en el desarrollo, desplegar estas nubes, desplegar las aplicaciones que escribimos y desarrollar directamente las herramientas que proporcionamos a nuestros usuarios.
DevOps- , , , , . , , , DevOps, , , . . Kubernetes â , , , .
, Kubernetes 1.3, , 1.2 â . â , , Kubernetes . . , , .
, , , (TL;DR) â «too long; donât read». .
, , , , , , - .
â «ctrl+c, ctrl+v», , DevOps, : «, Kubernetes, ».
. . , .
:
- , -, ( ?), Kubernetes, , ;
- Kubernetes, Kubernetes - ;
- , , ;
- , graceful shutdown;
- ;
- ;
- , cloud-native . Cloudnativeness, .
â , Kubernetes . Kubernetes . , - . , . - /var/log
.
, , - , â rsyslog , - , , , , , , , -. , , - , , ( ?) . , , - .
Kubernetes , , â , , , .
, Kubernetes, , - - , Stdout/Stderr, , . , , . , Stdout/Stderr, Kubernetes, . JSON .
, . , , kubectl logs
«». , , â - .
, , , . , Kubernetes, , , .
- , -, , , - . , Kubernetes DaemonSet - â , , , . - , , - , - , , -. . , , Elasticsearch, , . , Kibana, , , .
, , , , , Kubernetes, â .
-, . , exec, . â , , . , , . , , , , , . , â . , .
â , â . , , . , , , , . , -, , , â , , . , , , , Kubernetes, â .
, â , , , , . , Kubernetes, DevOps. â Dev Ops, .
, , JSON . - , , - print - , - , - , ; JSON, JSON , .
JSON - , , , . , , , , , - nginx, , , , , . nginx instance , -. , , , nginx instance , . .
, , , . , - , , , , , , . , , , , -, . -, .
stack trace â . , â , . - Elasticsearch , - , stack trace â , - , . stack trace - , .
( Sentry), , stack trace. , -, , , . , , , , -, .
Kubernetes: Kubernetes . , , â . , â , , . , .
, , . : , .
â , â ENV (environment) , , . , , JAVA, Python, Go, Perl , database host, database user, database password, . . .
ENV . Kubernetes, ENV Deployment. , , ENV ( ..), , ENV Deployment , , database password . Kubernetes. . , . DevOps, : «, , . ».
, . , postgres database, database name, database -, dbn - , , , .
, , Deployment â . , â . , . , .
, â , . Config.pi â , . - , â , .
, , , , .yaml. , , , , .
, YAML, , , JSON, , YAML . . , - ini. , , , , - , ini .
, , , Kubernetes â . Kubernetes, ConfigMap. configmap - , configmap , . , , , , . - , .
configmap, , , , configmap, . .
, , â , , . . , , , git. , git, git, â . , , git .
Health check
â , Health check. , Health check â , . -, , , ( ) - URL, , /health
.
URL, , «, , 200» «, , - 500». , http, -, - , , . , , http, . -, daemon - , , daemon status
, «, , daemon , ».
? , , â , , . , , , , , . , , , , â « , ..., , ».
â - , . . . Kubernetes, , , , , , . - java- , , , , . , , .
, , , Kubernetes, , , , .
, , Readiness/Liveness Kubernetes, , readiness - . readiness , , . readiness , , instance, , , . , Liveness Kubernetes , , «», «». liveness , Kubernetes, , .
, , , - readiness , liveness . readiness, liveness , Kubernetes , , â . . â , . , -, - , , , - . , . , , REST API . , , «200, , », , «200, , » â . .
, , /health
, , «200, », , , , , - , , , . , «200, ». , , , .
, , Readiness/Liveness â readiness , liveness . , , , instance instance
, . readiness , , , , «» , .
liveness , , , Kubernetes , liveness- . , . , , . , JS Mongo. - , Kubernetes, readiness, liveness , Kubernetes â . , - Mongo «» . , «».
, «», , , . «» â , â - , , - , - , . , , instance. , , , , , , , , . , , . , . â , instance , instances.
liveness , , . , «». , , , , . , , , , â , .
, readiness liveness , , , , , , . readiness . liveness , , , , liveness , .
liveness «». - â . â .
, , , . . , , , â , , «200». , . « -».
â . , «, » . .
- , - , - . , -.
, . , . , , : 204, 5, 10, 15, . , « ». , . , , , . , 502 â , - .
, . , , , â . , , « » â , . , . . , , , - , - , , â . .
, , . , , REST API, , , .
, , - , , , â , , - .
.
, Kubernetes , , - DevOps , Kubernetes. , (graceful) Kubernetes. Kubernetes , Kubernetes .
Graceful Shutdown
, Graceful Shutdown . , - , app stop
â , , , - . , , SIGTERM «SIGTERM, , , ». .
, SIGTERM « , , , , , SIGTERM, ». .
? , . â - , , SIGTERM.
SIGTERM â , , , , , , , , , .
Kubernetes, . , Kubernetes, «, , » , , Kubernetes â Kubernetes - SIGTERM, - , , , , , Graceful ShutdownTimeout. , .
, , SIGTERM , - , «» â SIGKILL, , . , , - , . , , , 30 . , SIGTERM, , SIGTERM 30 . , , 45 , SIGTERM. 45 . , . , , , , â . 45 , , .
, , 2 . -, , , , - , SIGTERM, . . . , , , , - , - , -. , , , â , , . , , SIGTERM . , SIGTERM. , . , . , - websocket, , , , , . , .
, - exit-. , , , - exit- 1,5,255 . , , Linux , , . , . , -, , 0 . - , 0 . .
. , , . , . , . , , , . , , . â , â . websocket`, , .
- , , , websocket . - , , reload. , . : «, , !». : « ? ?». : «, , ». , . . , , websocket, . .
, . . , .
, , - , , Kubernetes . , ⊠- : « ». , , , . , - . : «- , ». : « ?». , Kubernetes, , , . , : « , . ». . . , , .
? Kubernetes 2 . , â . , . , Kubernetes.
. , , 1 , 1 . , , oom killer, out of memory , â . CPU . CPU, , , , CPU . . â .
. â , Kubernetes , Kubernetes . â commit . , : « , CPU ». . node, , , 8 CPU. , 1 CPU, 7 CPU. , , 8 , 1 â , Kubernetes, CPU . CPU , Kubernetes , , , CPU.
, , Kubernetes ? , . , Kubernetes , , . , , . - . , . , . , , . , , (). , , , . . , , . , .
, , , Kubernetes. Kubernetes , , . . . , .
. , persistence Kubernetes?
, , , Kubernetes . , , : « Kubernetes ?». -, , , , , Kubernetes , .
. , , , , , cloud native . , , . , , , . . .
, , - , , - , , , ? Kubernetes ?
, , , Kubernetes stateless . , . .
, , , . ? â - S3, , , - . â S3. , « , , S3 ». , : « S3 ». .
- , , , , - , S3 , . - - , Kubernetes. Ceph - , , . Ceph, , . , , - Ceph, . , , Ceph , . Ceph , .
- NFS . Kubernetes , NFS â . , , , , NFS - , , , , , . , - .
, , , - . , , , - , - , . . , , . , . , , - , -, , - . , , . . Kubernetes . , instance . , . . Kubernetes , , instances. Kubernetes . , , , . . instance - . , , , . , , , , . , , , .
, Kubernetes , volume. , volume empty dir. Kubernetes , , . , . . , , . Kubernetes empty dirs . , empty dir, . , empty dir . â . - , , . , , empty dir, , empty dir .
empty dir? , . , - , . , , , -, , , . Empty dir Kubernetes . , â . empty dir , , , , . - . , , , . Kubernetes.
Minio ? Minio â , , , - , - , . , Ceph. Minio - . HTTP . , S3. . , , buckets , , , â , , .
Empty dir ? . , , , . empty dir , . . , , kubernetes, , , empty dir. , , - , - , - empty dir .
Cloudnativeness
, Cloudnative. . Cloudnativeness .
, , . , , Cloudnative . , , , , . , , .
Kubernetes. Kubernetes. , , -. Kubernetes . - , . Kubernetes . ? , , , - Kubernetes, .
, . , , . - , Kubernetes â Kubernetes . - , , , - . , , . , Kubernetes. Kubernetes , - . - , , . Kubernetes , .
, Kubernetes. - Kubernetes â , - . , , , , , . , . , , . , . , -, , , . , Kubernetes .
. Kubernetes . , , , â Kubernetes . , . , Kubernetes , , . . . , , , , .
, , . Cloudnative . , . 9 , , , Cloudnative, , , , , , . 8 6 , Kubernetes , . 30 . , , .
, 30 - , Kubernetes, . . , , , , , .
, . , , Cloudnative, - , Infrastructure as a Code. , , , , . , , , git, CI\CD .
, , -, , . -, , . -, , , . -, . , , , : «, , , , ». . - , Cloudnative Infrastructure as a Code, , , , , . .
Kubernetes: , , . . , Kubernetes, 1-2 .