{"id":414903,"date":"2024-06-30T00:02:29","date_gmt":"2024-06-30T00:02:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=414903"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=414903","title":{"rendered":"<span>\u0413\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u044b\u0441\u043e\u043a\u043e\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 memcached \u0441 mcrouter \u0432 Kubernetes<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ba\/550\/ada\/2ba550ada38e1948c64ceebbe973c7b0.png\" width=\"780\" height=\"450\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ba\/550\/ada\/2ba550ada38e1948c64ceebbe973c7b0.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439: \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0411\u0414 \u0431\u044b\u043b\u0430 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430 \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e RPS (requests per second). \u041e\u0434\u043d\u0430\u043a\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438\u0437 \u0411\u0414, \u0431\u044b\u043b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0432\u0435\u043b\u0438\u043a. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0411\u0414 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u043b \u0440\u043e\u0441\u0442 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a \u043d\u0435\u0439 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u043b\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0432\u044b\u0437\u0432\u0430\u043b\u043e \u044d\u0444\u0444\u0435\u043a\u0442 \u0441\u043d\u0435\u0436\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u0430. <\/p>\n<p>\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e: \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0440\u043e\u043b\u0438 \u043a\u044d\u0448\u0430 \u0432\u044b\u0441\u0442\u0443\u043f\u0438\u043b\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <a href=\"https:\/\/memcached.org\/\"><u>memcached<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043d\u044f\u043b\u043e \u043d\u0430 \u0441\u0435\u0431\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Kubernetes \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438\u2026<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 K8s \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u044b\u0438\u0433\u0440\u0430\u043b \u0432 \u0446\u0435\u043b\u043e\u043c \u0437\u0430 \u0441\u0447\u0435\u0442 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u0441 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043e\u0442\u0437\u044b\u0432\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043d\u0438\u0437\u0438\u043b\u0430\u0441\u044c. \u0410\u043d\u0430\u043b\u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 New Relic \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432 memcached.<\/p>\n<p>\u042f \u0441\u0442\u0430\u043b \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0432\u043e\u0437\u0440\u043e\u0441\u0448\u0438\u0445 \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a \u0438 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439. \u0415\u0441\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 memcached \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0443\u0437\u043b\u0435, \u0442\u043e \u0432 K8s-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Pod \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 Pod \u0441 memcached \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0437\u043b\u0430\u0445. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u044b \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p><strong><em>NB.<\/em><\/strong><em> \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0438\u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u0430 \u0432 production-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0441 10 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 memcached. \u041d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u044f\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c.<\/em><\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e memcached \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 DaemonSet \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0443\u0437\u043b\u0430\u0445, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/scheduling-eviction\/assign-pod-node\/\"><u>node affinity<\/u><\/a>. \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u0439 \u043a production \u043b\u0438\u0441\u0442\u0438\u043d\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c probes \u0438 requests\/limits:<\/p>\n<pre><code class=\"yaml\">apiVersion: apps\/v1 kind: DaemonSet metadata:  name: mc  labels:    app: mc spec:  selector:    matchLabels:      app: mc  template:    metadata:      labels:        app: mc    spec:      affinity:        nodeAffinity:          requiredDuringSchedulingIgnoredDuringExecution:            nodeSelectorTerms:            - matchExpressions:              - key: node-role.kubernetes.io\/node                operator: Exists      containers:      - name: memcached        image: memcached:1.6.9        command:        - \/bin\/bash        - -c        - --        - memcached --port=30213 --memory-limit=2048 -o modern v --conn-limit=4096 -u memcache        ports:        - name: mc-production          containerPort: 30213        livenessProbe:          tcpSocket:            port: mc-production          initialDelaySeconds: 30          timeoutSeconds: 5        readinessProbe:          tcpSocket:            port: mc-production          initialDelaySeconds: 5          timeoutSeconds: 1        resources:          requests:            cpu: 100m            memory: 2560Mi          limits:            memory: 2560Mi --- apiVersion: v1 kind: Service metadata:  name: mc spec:  selector:    app: mc  clusterIP: None  publishNotReadyAddresses: true  ports:  - name: mc-production    port: 30213<\/code><\/pre>\n<p>\u041d\u043e \u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D0%B3%D0%B5%D1%80%D0%B5%D0%BD%D1%82%D0%BD%D0%BE%D1%81%D1%82%D1%8C_%D0%BA%D1%8D%D1%88%D0%B0\"><u>\u043a\u043e\u0433\u0435\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/u><\/a> \u043a\u044d\u0448\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 \u043a\u044d\u0448\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u043e\u0447\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0411\u0414. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0432 \u0411\u0414 \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0438 \u0432 memcached. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0431\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430, \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0443\u0437\u043b\u043e\u0432, \u043d\u0430 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 memcached \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 <a href=\"https:\/\/github.com\/facebook\/mcrouter\"><u>mcrouter<\/u><\/a> \u2014 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f memcached-\u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u0439. \u041c\u044b \u0443\u0436\u0435 \u0434\u0430\u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/457510\/\"><u>\u043f\u0438\u0441\u0430\u043b\u0438 \u043e \u043d\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u044e<\/u><\/a>.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 mcrouter<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u044d\u0448\u0430, mcrouter \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u043a DaemonSet. \u0422\u0430\u043a mcrouter \u0431\u0443\u0434\u0435\u0442 \u00ab\u0437\u043d\u0430\u0442\u044c\u00bb, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 memcached \u2014 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439, \u0442. \u0435. \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430 \u0435\u0433\u043e \u0443\u0437\u043b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e mcrouter \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c sidecar-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c \u0432 Pod\u2019\u044b \u0441 memcached. \u0422\u043e\u0433\u0434\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 memcached \u0434\u043b\u044f mcrouter\u2019a \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 127.0.0.1.<\/p>\n<p>\u041d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c, \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c mcrouter \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 DaemonSet \u0438 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 memcached \u0438 mcrouter \u0432 hostNetwork. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c memcached \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u043a\u044d\u0448\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0435\u0432\u044b\u043a\u0430\u0442 \u043a\u0430\u043a \u0434\u043b\u044f memcached, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f mcrouter \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438 \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c memcached \u0432 hostNetwork, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442: <code>hostNetwork: true<\/code>.<\/p>\n<p>\u00a0\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0441 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0443\u0437\u043b\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d Pod, \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 memcached:<\/p>\n<pre><code class=\"yaml\">       env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP<\/code><\/pre>\n<p>\u0418 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 memcached, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0440\u0442 \u0431\u044b\u043b \u043e\u0442\u043a\u0440\u044b\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c IP \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"yaml\">       command:        - \/bin\/bash        - -c        - --        - memcached --listen=$HOST_IP --port=30213 --memory-limit=2048 -o modern v --conn-limit=4096 -u memcache<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0448\u0435\u043c DaemonSet mcrouter\u2019a, Pod\u2019\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432 hostNetwork:<\/p>\n<pre><code class=\"yaml\">apiVersion: apps\/v1 kind: DaemonSet metadata:  name: mcrouter  labels:    app: mcrouter spec:  selector:    matchLabels:      app: mcrouter  template:    metadata:      labels:        app: mcrouter    spec:      affinity:        nodeAffinity:          requiredDuringSchedulingIgnoredDuringExecution:            nodeSelectorTerms:            - matchExpressions:              - key: node-role.kubernetes.io\/node                operator: Exists      hostNetwork: true      imagePullSecrets:      - name: \"registrysecret\"      containers:      - name: mcrouter        image: {{ .Values.werf.image.mcrouter }}        command:        - \/bin\/bash        - -c        - --        - mcrouter --listen-addresses=$HOST_IP --port=31213 --config-file=\/mnt\/config\/config.json --stats-root=\/mnt\/config\/        volumeMounts:        - name: config          mountPath: \/mnt\/config        ports:        - name: mcr-production          containerPort: 30213        livenessProbe:          tcpSocket:            port: mcr-production          initialDelaySeconds: 30          timeoutSeconds: 5        readinessProbe:          tcpSocket:            port: mcr-production          initialDelaySeconds: 5          timeoutSeconds: 1        resources:          requests:            cpu: 300m            memory: 100Mi          limits:            memory: 100Mi        env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP      volumes:      - configMap:          name: mcrouter        name: mcrouter      - name: config        emptyDir: {}<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 mcrouter \u0442\u043e\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432 hostNetwork, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0440\u0442 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c IP \u0443\u0437\u043b\u043e\u0432.<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u0431\u043e\u0440\u043a\u0438 mcrouter, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/werf.io\"><u>werf<\/u><\/a> (\u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Dockerfile, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c):<\/p>\n<pre><code class=\"yaml\">image: mcrouter from: ubuntu:18.04 mount: - from: tmp_dir  to: \/var\/lib\/apt\/lists ansible: beforeInstall: - name: Install prerequisites   apt:     name:     - apt-transport-https     - apt-utils     - dnsutils     - gnupg     - tzdata     - locales     update_cache: yes - name: Add mcrouter APT key   apt_key:     url: https:\/\/facebook.github.io\/mcrouter\/debrepo\/bionic\/PUBLIC.KEY - name: Add mcrouter Repo   apt_repository:     repo: deb https:\/\/facebook.github.io\/mcrouter\/debrepo\/bionic bionic contrib     filename: mcrouter     update_cache: yes - name: Set timezone   timezone:     name: \"Europe\/Moscow\" - name: Ensure a locale exists   locale_gen:     name: en_US.UTF-8     state: present install: - name: Install mcrouter   apt:     name:     - mcrouter<\/code><\/pre>\n<p>\u0418 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b mcrouter. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043b\u0435\u0442\u0443, \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 Pod\u2019\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0443\u0437\u043b\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u00ab\u0441\u0432\u043e\u0435\u0433\u043e\u00bb \u0443\u0437\u043b\u0430 \u043a\u0430\u043a \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u044b\u0439 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c init-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0432 Pod\u2019\u0435 \u0441 mcrouter\u2019\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u0434\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043e\u0431\u0449\u0438\u0439 volume \u0432 <code>emptyDir<\/code>:<\/p>\n<pre><code class=\"yaml\">     initContainers:      - name: init        image: {{ .Values.werf.image.mcrouter }}        command:        - \/bin\/bash        - -c        - \/mnt\/config\/config_generator.sh \/mnt\/config\/config.json        volumeMounts:        - name: mcrouter          mountPath: \/mnt\/config\/config_generator.sh          subPath: config_generator.sh        - name: config          mountPath: \/mnt\/config        env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0430\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 init-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435:<\/p>\n<pre><code class=\"yaml\">apiVersion: v1 kind: ConfigMap metadata:  name: mcrouter data:  config_generator.sh: |    #!\/bin\/bash    set -e    set -o pipefail      config_path=$1;    if [ -z \"${config_path}\" ]; then echo \"config_path isn't specified\"; exit 1; fi      function join_by { local d=$1; shift; local f=$1; shift; printf %s \"$f\" \"${@\/#\/$d}\"; }      mapfile -t ips &lt; &lt;( host mc.production.svc.cluster.local 10.222.0.10 | grep mc.production.svc.cluster.local | awk '{ print $4; }' | sort | grep -v $HOST_IP )      delimiter=':30213\",\"'      servers='\"'$(join_by $delimiter $HOST_IP \"${ips[@]}\")':30213\"'      cat &lt;&lt;&lt; '{      \"pools\": {        \"A\": {          \"servers\": [            '$servers'          ]        }      },      \"route\": {        \"type\": \"OperationSelectorRoute\",        \"operation_policies\": {          \"add\": \"AllSyncRoute|Pool|A\",          \"delete\": \"AllSyncRoute|Pool|A\",          \"get\": \"FailoverRoute|Pool|A\",          \"set\": \"AllSyncRoute|Pool|A\"        }      }    }    ' > $config_path<\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c\u0443 DNS \u0432 K8s-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f Pod\u2019\u043e\u0432 memcached \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u2014 IP-\u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430\u0448 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 mcrouter.<\/p>\n<p><strong><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/em><\/strong><em> \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a DNS \u0431\u044b\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 Pod\u2019\u043e\u0432, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435 Service \u0434\u043b\u044f memcached \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f <\/em><code>clusterIP: None<\/code><em>.<\/em><\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"json\">cat \/mnt\/config\/config.json {   \"pools\": {     \"A\": {       \"servers\": [ \"192.168.100.33:30213\",\"192.168.100.14:30213\",\"192.168.100.15:30213\",\"192.168.100.16:30213\",\"192.168.100.21:30213\",\"192.168.100.22:30213\",\"192.168.100.23:30213\",\"192.168.100.34:30213\"       ]     }   },   \"route\": {     \"type\": \"OperationSelectorRoute\",     \"operation_policies\": {       \"add\": \"AllSyncRoute|Pool|A\",       \"delete\": \"AllSyncRoute|Pool|A\",       \"get\": \"FailoverRoute|Pool|A\",       \"set\": \"AllSyncRoute|Pool|A\"     }   } }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043c\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 \u0432\u0441\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b memcached \u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u043e \u00ab\u0441\u0432\u043e\u0435\u0433\u043e\u00bb \u0443\u0437\u043b\u0430.<\/p>\n<p><strong>NB<\/strong>. \u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u0433\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043e\u0433\u0435\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u044d\u0448\u0430 \u043d\u0435\u0442, \u0442\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e AllSyncRoute \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 AllMajorityRoute \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 AllFastestRoute.<\/p>\n<h2>\u041f\u043e\u043f\u0440\u0430\u0432\u043a\u0430 \u043d\u0430 \u0432\u0435\u0442\u0435\u0440<\/h2>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u2014 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f. \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u0443\u0437\u043b\u043e\u0432 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0430 \u043a\u043e\u0433\u0435\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u044d\u0448\u0430:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b memcached \u0438 mcrouter.<\/p>\n<\/li>\n<li>\n<p><em>\u041d\u043e\u0432\u044b\u0435<\/em> \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b mcrouter \u0431\u0443\u0434\u0443\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 <em>\u0441\u0442\u0430\u0440\u044b\u0435<\/em> \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b memcached. \u0410 \u0441\u0442\u0430\u0440\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b mcrouter \u043e \u043d\u043e\u0432\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 memcached \u043d\u0435 \u0443\u0437\u043d\u0430\u044e\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 <em>\u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f<\/em> \u0447\u0438\u0441\u043b\u0430 \u0443\u0437\u043b\u043e\u0432 \u2014 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 mcrouter \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 AllSyncRoute \u2014 \u043a\u044d\u0448 \u043d\u0430 \u0443\u0437\u043b\u0430\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c read-only.<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f: \u0432 Pod\u2019\u0435 \u0441 mcrouter\u2019\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c sidecar-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 cron\u2019\u043e\u043c, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u044b \u0434\u0435\u043b\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0443\u0437\u043b\u043e\u0432 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f sidecar\u2019\u0430:<\/p>\n<pre><code class=\"yaml\">     - name: cron        image: {{ .Values.werf.image.cron }}        command:        - \/usr\/local\/bin\/dumb-init        - \/bin\/sh        - -c        - \/usr\/local\/bin\/supercronic -json \/app\/crontab        volumeMounts:        - name: mcrouter          mountPath: \/mnt\/config\/config_generator.sh          subPath: config_generator.sh        - name: mcrouter          mountPath: \/mnt\/config\/check_nodes.sh          subPath: check_nodes.sh        - name: mcrouter          mountPath: \/app\/crontab          subPath: crontab        - name: config          mountPath: \/mnt\/config        resources:          limits:            memory: 64Mi          requests:            memory: 64Mi            cpu: 5m        env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP<\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0432 \u044d\u0442\u043e\u043c cron\u2019\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 <code>config_generator.sh<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 init-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435:<\/p>\n<pre><code class=\"bash\"> crontab: |    # Check nodes in cluster    * * * * * * *   \/mnt\/config\/check_nodes.sh \/mnt\/config\/config.json    check_nodes.sh: |    #!\/usr\/bin\/env bash    set -e      config_path=$1;    if [ -z \"${config_path}\" ]; then echo \"config_path isn't specified\"; exit 1; fi      check_path=\"${config_path}.check\"      checksum1=$(md5sum $config_path | awk '{print $1;}')      \/mnt\/config\/config_generator.sh $check_path      checksum2=$(md5sum $check_path | awk '{print $1;}')      if [[ $checksum1 == $checksum2 ]]; then        echo \"No changes for nodes.\"        exit 0;    else        echo \"Node list was changed.\"        mv $check_path $config_path        echo \"mcrouter is reconfigured.\"    fi<\/code><\/pre>\n<p>\u0420\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f mcrouter. \u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e\u0434\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f mcrouter\u2019\u0443 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0449\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0432 <code>emptyDir<\/code>. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c mcrouter \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0442. \u043a. \u043e\u043d \u0441\u0430\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0440\u0430\u0437 \u0432 <a href=\"https:\/\/github.com\/facebook\/mcrouter\/blob\/168a35060ac504c4169896ca38f90354250c0bfb\/mcrouter\/mcrouter_options_list.h#L539\"><u>\u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/u><\/a>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 Pod\u2019\u0435 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c IP-\u0430\u0434\u0440\u0435\u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u2014 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 memcached. \u0410 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0440\u0442\u0430 memcached \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u0440\u0442 mcrouter\u2019a:<\/p>\n<pre><code class=\"yaml\">       env:        - name: MEMCACHED_HOST          valueFrom:            fieldRef:              fieldPath: status.hostIP        - name: MEMCACHED_PORT          value: 31213<\/code><\/pre>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0446\u0435\u043b\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u044b\u043b\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430: \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e \u0434\u0430\u043d\u043d\u044b\u043c New Relic, \u0432\u0440\u0435\u043c\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 memcached \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u0441 70-80 \u043c\u0441 \u0434\u043e ~20 \u043c\u0441.<\/p>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ff1\/51b\/40f\/ff151b40fdd2de52ea0caafed479fbc9.png\" width=\"1604\" height=\"790\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ff1\/51b\/40f\/ff151b40fdd2de52ea0caafed479fbc9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bdf\/6ac\/e32\/bdf6ace322306a57c6aba93dfeeb4a0d.png\" width=\"1598\" height=\"792\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bdf\/6ac\/e32\/bdf6ace322306a57c6aba93dfeeb4a0d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 production \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u0433\u043e\u0434\u0430, \u0438 \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439 \u043d\u0435 \u0432\u0441\u043f\u043b\u044b\u043b\u043e.<\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438, \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 (Helm-\u0447\u0430\u0440\u0442\u044b \u0438 <code>werf.yaml)<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 <a href=\"https:\/\/github.com\/flant\/examples\/tree\/master\/2021\/09-memcached-mcrouter\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 flant\/examples<\/u><\/a>.<\/p>\n<h2>P.S.<\/h2>\n<p>\u0427\u0438\u0442\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u0431\u043b\u043e\u0433\u0435:<\/p>\n<ul>\n<li>\n<p>\u00ab<a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/457510\/\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c mcrouter \u0434\u043b\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f memcached<\/a>\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u00ab<a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/478404\/\">KeyDB \u043a\u0430\u043a [\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f] \u0437\u0430\u043c\u0435\u043d\u0430 Redis<\/a>\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u00ab<a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/450662\/\">\u0411\u0435\u0441\u043f\u0440\u043e\u0441\u0442\u043e\u0439\u043d\u0430\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f RabbitMQ \u0432 Kubernetes<\/a>\u00bb.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/575656\/\"> https:\/\/habr.com\/ru\/articles\/575656\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439: \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0411\u0414 \u0431\u044b\u043b\u0430 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430 \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e RPS (requests per second). \u041e\u0434\u043d\u0430\u043a\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438\u0437 \u0411\u0414, \u0431\u044b\u043b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0432\u0435\u043b\u0438\u043a. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0411\u0414 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u043b \u0440\u043e\u0441\u0442 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043a \u043d\u0435\u0439 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u043b\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0432\u044b\u0437\u0432\u0430\u043b\u043e \u044d\u0444\u0444\u0435\u043a\u0442 \u0441\u043d\u0435\u0436\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u0430. <\/p>\n<p>\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e: \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0440\u043e\u043b\u0438 \u043a\u044d\u0448\u0430 \u0432\u044b\u0441\u0442\u0443\u043f\u0438\u043b\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <a href=\"https:\/\/memcached.org\/\"><u>memcached<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043d\u044f\u043b\u043e \u043d\u0430 \u0441\u0435\u0431\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Kubernetes \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438\u2026<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 K8s \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u044b\u0438\u0433\u0440\u0430\u043b \u0432 \u0446\u0435\u043b\u043e\u043c \u0437\u0430 \u0441\u0447\u0435\u0442 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u0441 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043e\u0442\u0437\u044b\u0432\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043d\u0438\u0437\u0438\u043b\u0430\u0441\u044c. \u0410\u043d\u0430\u043b\u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 New Relic \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432 memcached.<\/p>\n<p>\u042f \u0441\u0442\u0430\u043b \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0432\u043e\u0437\u0440\u043e\u0441\u0448\u0438\u0445 \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a \u0438 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439. \u0415\u0441\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 memcached \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0443\u0437\u043b\u0435, \u0442\u043e \u0432 K8s-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Pod \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 Pod \u0441 memcached \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0437\u043b\u0430\u0445. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u044b \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p><strong><em>NB.<\/em><\/strong><em> \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043d\u0438\u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u0430 \u0432 production-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0441 10 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 memcached. \u041d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u044f\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u043e\u0441\u044c.<\/em><\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e memcached \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 DaemonSet \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0443\u0437\u043b\u0430\u0445, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/scheduling-eviction\/assign-pod-node\/\"><u>node affinity<\/u><\/a>. \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439, \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u0439 \u043a production \u043b\u0438\u0441\u0442\u0438\u043d\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c probes \u0438 requests\/limits:<\/p>\n<pre><code class=\"yaml\">apiVersion: apps\/v1 kind: DaemonSet metadata:  name: mc  labels:    app: mc spec:  selector:    matchLabels:      app: mc  template:    metadata:      labels:        app: mc    spec:      affinity:        nodeAffinity:          requiredDuringSchedulingIgnoredDuringExecution:            nodeSelectorTerms:            - matchExpressions:              - key: node-role.kubernetes.io\/node                operator: Exists      containers:      - name: memcached        image: memcached:1.6.9        command:        - \/bin\/bash        - -c        - --        - memcached --port=30213 --memory-limit=2048 -o modern v --conn-limit=4096 -u memcache        ports:        - name: mc-production          containerPort: 30213        livenessProbe:          tcpSocket:            port: mc-production          initialDelaySeconds: 30          timeoutSeconds: 5        readinessProbe:          tcpSocket:            port: mc-production          initialDelaySeconds: 5          timeoutSeconds: 1        resources:          requests:            cpu: 100m            memory: 2560Mi          limits:            memory: 2560Mi --- apiVersion: v1 kind: Service metadata:  name: mc spec:  selector:    app: mc  clusterIP: None  publishNotReadyAddresses: true  ports:  - name: mc-production    port: 30213<\/code><\/pre>\n<p>\u041d\u043e \u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D0%B3%D0%B5%D1%80%D0%B5%D0%BD%D1%82%D0%BD%D0%BE%D1%81%D1%82%D1%8C_%D0%BA%D1%8D%D1%88%D0%B0\"><u>\u043a\u043e\u0433\u0435\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/u><\/a> \u043a\u044d\u0448\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 \u043a\u044d\u0448\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u043e\u0447\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0411\u0414. \u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0432 \u0411\u0414 \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0438 \u0432 memcached. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0431\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430, \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0443\u0437\u043b\u043e\u0432, \u043d\u0430 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 memcached \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 <a href=\"https:\/\/github.com\/facebook\/mcrouter\"><u>mcrouter<\/u><\/a> \u2014 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f memcached-\u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u0439. \u041c\u044b \u0443\u0436\u0435 \u0434\u0430\u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/457510\/\"><u>\u043f\u0438\u0441\u0430\u043b\u0438 \u043e \u043d\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u044e<\/u><\/a>.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 mcrouter<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u044d\u0448\u0430, mcrouter \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u043a DaemonSet. \u0422\u0430\u043a mcrouter \u0431\u0443\u0434\u0435\u0442 \u00ab\u0437\u043d\u0430\u0442\u044c\u00bb, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 memcached \u2014 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439, \u0442. \u0435. \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430 \u0435\u0433\u043e \u0443\u0437\u043b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e mcrouter \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c sidecar-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c \u0432 Pod\u2019\u044b \u0441 memcached. \u0422\u043e\u0433\u0434\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 memcached \u0434\u043b\u044f mcrouter\u2019a \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 127.0.0.1.<\/p>\n<p>\u041d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c, \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c mcrouter \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 DaemonSet \u0438 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 memcached \u0438 mcrouter \u0432 hostNetwork. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043b\u044e\u0431\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c memcached \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u043a\u044d\u0448\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0435\u0432\u044b\u043a\u0430\u0442 \u043a\u0430\u043a \u0434\u043b\u044f memcached, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f mcrouter \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u0438 \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c memcached \u0432 hostNetwork, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442: <code>hostNetwork: true<\/code>.<\/p>\n<p>\u00a0\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0441 IP-\u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0443\u0437\u043b\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d Pod, \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 memcached:<\/p>\n<pre><code class=\"yaml\">       env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP<\/code><\/pre>\n<p>\u0418 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 memcached, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0440\u0442 \u0431\u044b\u043b \u043e\u0442\u043a\u0440\u044b\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c IP \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"yaml\">       command:        - \/bin\/bash        - -c        - --        - memcached --listen=$HOST_IP --port=30213 --memory-limit=2048 -o modern v --conn-limit=4096 -u memcache<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0448\u0435\u043c DaemonSet mcrouter\u2019a, Pod\u2019\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432 hostNetwork:<\/p>\n<pre><code class=\"yaml\">apiVersion: apps\/v1 kind: DaemonSet metadata:  name: mcrouter  labels:    app: mcrouter spec:  selector:    matchLabels:      app: mcrouter  template:    metadata:      labels:        app: mcrouter    spec:      affinity:        nodeAffinity:          requiredDuringSchedulingIgnoredDuringExecution:            nodeSelectorTerms:            - matchExpressions:              - key: node-role.kubernetes.io\/node                operator: Exists      hostNetwork: true      imagePullSecrets:      - name: \"registrysecret\"      containers:      - name: mcrouter        image: {{ .Values.werf.image.mcrouter }}        command:        - \/bin\/bash        - -c        - --        - mcrouter --listen-addresses=$HOST_IP --port=31213 --config-file=\/mnt\/config\/config.json --stats-root=\/mnt\/config\/        volumeMounts:        - name: config          mountPath: \/mnt\/config        ports:        - name: mcr-production          containerPort: 30213        livenessProbe:          tcpSocket:            port: mcr-production          initialDelaySeconds: 30          timeoutSeconds: 5        readinessProbe:          tcpSocket:            port: mcr-production          initialDelaySeconds: 5          timeoutSeconds: 1        resources:          requests:            cpu: 300m            memory: 100Mi          limits:            memory: 100Mi        env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP      volumes:      - configMap:          name: mcrouter        name: mcrouter      - name: config        emptyDir: {}<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 mcrouter \u0442\u043e\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432 hostNetwork, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0440\u0442 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c IP \u0443\u0437\u043b\u043e\u0432.<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u0431\u043e\u0440\u043a\u0438 mcrouter, \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/werf.io\"><u>werf<\/u><\/a> (\u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Dockerfile, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c):<\/p>\n<pre><code class=\"yaml\">image: mcrouter from: ubuntu:18.04 mount: - from: tmp_dir  to: \/var\/lib\/apt\/lists ansible: beforeInstall: - name: Install prerequisites   apt:     name:     - apt-transport-https     - apt-utils     - dnsutils     - gnupg     - tzdata     - locales     update_cache: yes - name: Add mcrouter APT key   apt_key:     url: https:\/\/facebook.github.io\/mcrouter\/debrepo\/bionic\/PUBLIC.KEY - name: Add mcrouter Repo   apt_repository:     repo: deb https:\/\/facebook.github.io\/mcrouter\/debrepo\/bionic bionic contrib     filename: mcrouter     update_cache: yes - name: Set timezone   timezone:     name: \"Europe\/Moscow\" - name: Ensure a locale exists   locale_gen:     name: en_US.UTF-8     state: present install: - name: Install mcrouter   apt:     name:     - mcrouter<\/code><\/pre>\n<p>\u0418 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b mcrouter. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043b\u0435\u0442\u0443, \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 Pod\u2019\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0443\u0437\u043b\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u00ab\u0441\u0432\u043e\u0435\u0433\u043e\u00bb \u0443\u0437\u043b\u0430 \u043a\u0430\u043a \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u044b\u0439 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c init-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0432 Pod\u2019\u0435 \u0441 mcrouter\u2019\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u0434\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043e\u0431\u0449\u0438\u0439 volume \u0432 <code>emptyDir<\/code>:<\/p>\n<pre><code class=\"yaml\">     initContainers:      - name: init        image: {{ .Values.werf.image.mcrouter }}        command:        - \/bin\/bash        - -c        - \/mnt\/config\/config_generator.sh \/mnt\/config\/config.json        volumeMounts:        - name: mcrouter          mountPath: \/mnt\/config\/config_generator.sh          subPath: config_generator.sh        - name: config          mountPath: \/mnt\/config        env:        - name: HOST_IP          valueFrom:            fieldRef:              fieldPath: status.hostIP<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0430\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 init-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435:<\/p>\n<pre><code class=\"yaml\">apiVersion: v1 kind: ConfigMap metadata:  name: mcrouter data:  config_generator.sh: |    #!\/bin\/bash    set -e    set -o pipefail      config_path=$1;    if [ -z \"${config_path}\" ]; then echo \"config_path isn't specified\"; exit 1; fi      function join_by { local d=$1; shift; local f=$1; shift; printf %s \"$f\" \"${@\/#\/$d}\"; }      mapfile -t ips &lt; &lt;( host mc.production.svc.cluster.local 10.222.0.10 | grep mc.production.svc.cluster.local | awk '{ print $4; }' | sort | grep -v $HOST_IP )      delimiter=':30213\",\"'      servers='\"'$(join_by $delimiter $HOST_IP \"${ips[@]}\")':30213\"'      cat &lt;&lt;&lt; '{      \"pools\": {        \"A\": {          \"servers\": [            '$servers'          ]        }      },      \"route\": {        \"type\": \"OperationSelectorRoute\",        \"operation_policies\": {          \"add\": \"AllSyncRoute|Pool|A\",          \"delete\": \"AllSyncRoute|Pool|A\",          \"get\": \"FailoverRoute|Pool|A\",          \"set\": \"AllSyncRoute|Pool|A\"        }      }    }    ' > $config_path<\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c\u0443 DNS \u0432 K8s-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f Pod\u2019\u043e\u0432 memcached \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u2014 IP-\u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043d\u0430\u0448 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 mcrouter.<\/p>\n<p><strong><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/em><\/strong><em> \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a DNS \u0431\u044b\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 Pod\u2019\u043e\u0432, <\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-414903","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/414903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=414903"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/414903\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=414903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=414903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=414903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}