Requisitos para desarrollar una aplicaciĂłn en Kubernetes

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 , .



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 .




All Articles