GeezerVison is showing github.com — [EKS] 3. EKS chart and deploy · Issue #129 · fixpoint/ke2-docker
[EKS] 3. EKS chart and deploy #129Labels EKSAmazon EKS deployment work DescriptionGoal
One Helm chart runs the six KE workloads on EKS with the storage and the credentials, and the app step of deploy.sh installs the load balancer controller and KE.
Description
The chart is new and belongs to EKS only (ke2/cloud/eks/helm/ke2-app). It has the six workloads that ke2-docker has: kompira, kengine, jobmngrd, and nginx (3 pods each), RabbitMQ (3 pods), and Redis (1 pod). The design is in section 2: the shared config files come from the root configs/ folder, the storage is static Amazon EFS and Amazon EBS, and the two external Services are Network Load Balancers.
The app step is the second step of deploy.sh. The first step, infra, is E1. The upgrade in E4 uses only the app step.
Not in this issue: readiness, node spread, stop settings, and certificates (E3), the procedures for backup and upgrade (E4), and the guide (E5).
Implementation design
The diagram shows the workloads of the chart, their connections, and their storage.
flowchart LR
CL["Client"] --> NLB1["Network Load Balancer: ports 80 and 443"]
NLB1 --> NG["nginx x3"]
NG --> KO["kompira x3: port 8000"]
EX["External job manager"] --> NLB2["Network Load Balancer: port 5671"]
NLB2 --> RQ["RabbitMQ x3: EBS volume each"]
KO --> RQ
KE["kengine x3"] --> RQ
JM["jobmngrd x3"] --> RQ
KO --> RD["Redis x1"]
KO --> DB["Database: outside the template"]
KE --> DB
JM --> DB
EFS["EFS: kompira-var, kompira-log, ssl-cert"]
KO -.-> EFS
KE -.-> EFS
JM -.-> EFS
NG -.-> EFS
Loading
Config files:
-
ke2/cloud/eks/sync-configs.sh copies kompira.conf, kompira_audit.yaml, nginx.conf, rabbitmq-auth.conf, rabbitmq-ssl.conf, and rabbitmq-cluster.conf from the root configs/ folder into helm/ke2-app/files/. The copies are not committed (.gitignore). deploy.sh app runs the script, and CI runs it before the chart checks.
- Keep the EKS-only files in the chart and commit them: the RabbitMQ bootstrap script.
- Note: The bootstrap script of
ke2-docker (scripts/bootstrap-rabbitmq.sh) copies the certificate folder to /etc/rabbitmq/ssl, enables rabbitmq_auth_mechanism_ssl, and starts the server. The chart also needs the fixed list of the three nodes (section 2) and the certificate creation when the ssl-cert folder is empty.
- Build the ConfigMaps in the chart from these files with
.Files.Get, and add checksum annotations to every pod template, so that helm upgrade restarts the pods whose config changed.
Workloads:
- kompira (3 pods, command
uwsgi, port 8000), kengine (3 pods, command kompirad), and jobmngrd (3 pods, command jobmngrd), with the image kompira.azurecr.io/kompira-enterprise. They use the environment variables of ke2-docker (the database URL, the AMQP URL, the cache URL, MAX_EXECUTOR_NUM, the logging variables, and the uwsgi variables), the volumes kompira-var and kompira-log, and the config kompira_audit.yaml or kompira.conf. The pods of kompira and kengine set net.ipv4.tcp_keepalive_time to 1800.
- Note:
ke2-docker sets nproc and nofile to 65535 for kengine and jobmngrd. A pod has no field for this. The test reads the limits in the pods.
- Set the update strategy of the kompira, kengine, and jobmngrd Deployments to
Recreate.
- Note: These three use the same image, and the entrypoint runs the database migration at start, so the old and the new version must not run together.
ke2-docker stops the whole system for an update. A change of their config also restarts them together. nginx and Redis keep the default strategy.
- nginx (3 pods) with the image
nginx:1.27-alpine, ports 80 and 443, the config nginx.conf as a template, the nginx-env ConfigMap (NGINX_ENVSUBST_FILTER, KOMPIRA_HOST, KOMPIRA_PORT, and the two timeouts KOMPIRA_NGINX_UWSGI_READ_TIMEOUT and KOMPIRA_NGINX_UWSGI_SEND_TIMEOUT with 300 seconds as the default), and the volumes kompira-var and ssl-cert.
- RabbitMQ: a StatefulSet with 3 pods, the image
rabbitmq:3.13-alpine, a headless Service, the ports 5672 and 5671, the config files, the fixed list of the three nodes in the cluster config, and a volume of 10 GiB gp3 for each pod (the StorageClass with the binding mode WaitForFirstConsumer is in the chart).
- Redis: one pod with the image
redis:7.2-alpine, a Service, and no volume.
- Set the environment variable
HOSTNAME_SHORT on the pods of kompira and kengine from the node name: ap-<node name> for kompira and ke-<node name> for kengine, with the Downward API.
- Note: The audit log file is
audit-<HOSTNAME_SHORT>.log (kompira_site/settings.py in kompira-v2). Without this value the name has the pod name, which changes at every rollout, and old files are never removed. ke2-docker uses the container hostname ap-{{.Node.Hostname}} in Swarm.
Storage:
- Create the PVs and PVCs of the three access points in the chart from values (static provisioning): the driver
efs.csi.aws.com, the volume handle <file system ID>::<access point ID>, the mount option tls, the access mode ReadWriteMany, and the reclaim policy Retain. The volumes are kompira-var, kompira-log, and ssl-cert.
- Note:
deploy.sh app gives the IDs from the outputs of the infra step.
Services:
- Internal Services for kompira (8000), RabbitMQ (5672), and Redis (6379).
- Two external Services of type
LoadBalancer: nginx (ports 80 and 443) and RabbitMQ (port 5671), with the annotations aws-load-balancer-type: external, aws-load-balancer-nlb-target-type: ip, aws-load-balancer-scheme (internet-facing or internal, from the network mode), and aws-load-balancer-subnets (from the outputs). The value loadBalancer.sourceRanges (empty by default) sets loadBalancerSourceRanges on both Services.
- Note: Section 2 has the reasons. The idle timeout of a Network Load Balancer is 350 seconds, so no setting is needed. Client IP preservation stays off, so the audit log shows the address of the load balancer.
Credentials:
- Put the database password, the AMQP password, and the Erlang cookie in Kubernetes Secrets, not in ConfigMaps. The chart builds
DATABASE_URL and AMQP_URL from the values DATABASE_USER, DATABASE_NAME, AMQP_USER, and the Secrets, and it accepts existing Secrets.
- Note:
ke2-docker passes these values as plain environment values, so this item goes a little beyond it. It is small, because a Secret is the place for a password in Kubernetes.
- Make the RabbitMQ user and password configurable with
AMQP_USER and AMQP_PASSWORD, the same names as in ke2-docker. Use them in three places: RABBITMQ_DEFAULT_USER and RABBITMQ_DEFAULT_PASS of the RabbitMQ pods, the AMQP_URL of kompira, kengine, and jobmngrd, and the [amqp-connection] section of kompira.conf.
- Note: The two variables of the RabbitMQ image apply only at the first start on an empty data volume. The guide explains how to change the credentials later (E5). The values use only letters, digits, and
-_.~, because the chart builds the URLs without encoding, like the compose files of ke2-docker.
Values, versions, and checks:
- Set
version in Chart.yaml to the release date and appVersion to the default KE version. Do not set kubeVersion. Make the image tag a value with the tag that ke2-docker uses as the default (2.0.5-latest), and set imagePullPolicy: Always on the kompira, kengine, and jobmngrd containers.
- Add a small
values.schema.json (types, required values, and 3 for the RabbitMQ replica count), and NOTES.txt with the next steps, such as the addresses of the two load balancers and the copy of the .secret_key file outside the file system. --create-namespace creates the namespace.
- Add a GitHub Actions workflow for EKS that runs on every pull request and on every push to
develop and main, with no path filter. It runs cfn-lint on the template of E1, then sync-configs.sh, helm lint, and helm template.
Script deploy.sh:
-
./deploy.sh app reads the outputs of the infra step and takes the database and RabbitMQ values from environment variables with the ke2-docker names: DATABASE_HOST, DATABASE_PORT, DATABASE_USER, DATABASE_NAME, DATABASE_PASSWORD, AMQP_USER, AMQP_PASSWORD, and the optional KOMPIRA_IMAGE_TAG. It asks for DATABASE_PASSWORD if it is not set; AMQP_USER and AMQP_PASSWORD default to guest and guest, the same as ke2-docker (Environment.md), and are not prompted. It creates the namespace and the Secrets. For the Erlang cookie, it keeps the value of an existing Secret and creates a random value only if there is none.
-
./deploy.sh app installs the AWS Load Balancer Controller with Helm (chart 1.14.0, controller v2.14.1, with the cluster name, the region, and the VPC ID from the outputs), waits until the controller is available, runs sync-configs.sh, and runs helm upgrade --install for KE. It ends with kubectl get pods and the DNS names of the two load balancers.
- Note: The controller must be available before KE is installed, because it changes the Services when they are created.
helm install puts the controller CRDs in place, and helm upgrade does not, so the upgrade in E4 has the extra step. The AWS page lists the Gateway API CRDs as a prerequisite. The test confirms whether the controller starts without them, and if it does not, this step installs them.
Test plan
- Run
sync-configs.sh, then helm lint and helm template with the sample values. Expected: no errors, the ConfigMaps exist, the two external Services have the annotations, and every pod template has a checksum annotation.
- Run
git status after sync-configs.sh. Expected: the copied files under files/ do not show as changes, and they equal the root configs/ folder.
- Give the chart an invalid value: a text value for a replica count, and 2 for the RabbitMQ replica count. Expected: the schema rejects both.
- Run
./deploy.sh app after infra on a test cluster. Expected: the controller and KE install, all pods become Ready, and the script ends with the pod list and two DNS names.
- Open the DNS name of nginx from an allowed client. Expected: the login page of KE opens on port 443, and port 80 redirects to it.
- Run
rabbitmqctl cluster_status in a RabbitMQ pod. Expected: 3 nodes, and connect an AMQPS client to the DNS name of RabbitMQ on port 5671. Expected: it connects.
- Read the logs of the 3 kengine pods after the first install. Expected:
Generated secret key file and Data kompira.user(id=1) not exists each appear in exactly one pod.
- Read all ConfigMaps in the namespace. Expected: no password and no Erlang cookie in them. Try to log in to RabbitMQ with the built-in default account. Expected: the login fails.
- Deploy with a custom
AMQP_USER and AMQP_PASSWORD, then run ./deploy.sh app again. Expected: all components connect, and the second run has no error and no change.
- Change a value in the root
nginx.conf, run sync-configs.sh, and run helm upgrade. Expected: only the nginx pods restart. Change a RabbitMQ config file and run helm upgrade. Expected: the RabbitMQ pods restart one by one, the cluster stays healthy, and pods of other components do not restart.
- Change
kompira.conf through the root file, run sync-configs.sh, and run helm upgrade. Expected: all pods of kompira, kengine, and jobmngrd stop together and start again, and the pods of nginx and RabbitMQ do not restart.
- Uninstall and install again. Expected: no manual step, and the files on Amazon EFS and the data of RabbitMQ are still there.
- Run
kubectl rollout restart on kompira and kengine several times. Expected: no new audit-* file appears, and the files are named audit-ap-<node name>.log and audit-ke-<node name>.log.
- Log in to KE from a client outside the cluster, then read the audit file. Expected: the address in the entry is the address of the load balancer, as the guide says.
- Read
net.ipv4.tcp_keepalive_time in a kompira pod, and the limits nproc and nofile in a kengine pod and a jobmngrd pod. Expected: 1800 for the first, and the two limits are recorded.
- Run
helm template with and without an image tag value, and read the nginx config with nginx -T. Expected: the tag and the timeouts are the defaults without a value and the given values with one, and imagePullPolicy: Always is on the three containers.
- Open a pull request that changes the chart or the template, with a deliberate error. Expected: the workflow runs and fails. Push a change directly to
develop. Expected: the workflow runs.
ref
ke2-docker: configs/, scripts/bootstrap-rabbitmq.sh, ke2/services/kompira.yml, ke2/services/nginx.yml, ke2/services/jobmngrd.yml, ke2/services/rabbitmq.yml, ke2/services/redis.yml, Environment.md
kompira-v2: kompira_site/settings.py, docker/scripts/docker-entrypoint.sh
- AWS documentation: Amazon EKS User Guide (Install AWS Load Balancer Controller with Helm, Route TCP and UDP traffic with Network Load Balancers, the EFS CSI driver), Elastic Load Balancing User Guide (Network Load Balancers)
- Depends on: E1. Blocks: E3, E4, E5.
MetadataMetadataEKSAmazon EKS deployment work DevelopmentNo branches or pull requestsIssue actions
|