Horizontal Pod AutoScaler
Deployment placement
Note
the resource property of container must be set, otherwise the scaler can’t get your container runtime metrics
1 | kind: Deployment |
hpa
placement
1 | apiVersion: autoscaling/v2 |
gitlab runner auto rollout to kubernetes cluster
gitlab -> runner -> auto trigger kubectl roll update (/home/ubuntu/.kube
)
runner on kubernetes
if we want to let multiple repo run on same gitlab runner, we need to use register group runner (need to create a group)
create agent config file in project (optional)
To create an agent configuration file:
Choose a name for your agent. The agent name follows the DNS label standard from RFC 1123. The name must:
- Be unique in the project.
- Contain at most 63 characters.
- Contain only lowercase alphanumeric characters or -.
- Start with an alphanumeric character.
- End with an alphanumeric character.
- In the repository, in the default branch, create an agent configuration file at the root:
1 | .gitlab/agents/<agent-name>/config.yaml |
You can leave the file blank for now, and configure it later.
Register the agent with GitLab
1. Select Operate > Kubernetes clusters
2. Select Connect a cluster (agent)
* If you want to create a configuration with CI/CD defaults, type a name.
* If you already have an agent configuration file, select it from the list.
3. if you already have config file in your project, selec one. otherwise create a new one
4. get the access token
Update your .gitlab-ci.yml file to run kubectl commands
1. install kubernetes agent in your cluster through helm with the provided token
1 | helm repo add gitlab https://charts.gitlab.io |
2. check if gitlab has connected to the cluster agent
3. run kubectl in .gitlab-ci.yml
1 | deploy: |
notice: If you are not sure what your agent’s context is, open a terminal and connect to your cluster. Run kubectl config get-contexts
. (in my case, I need to execute the command directly in the gitlab ci triggered job)
- push the change to trigger the gitlab workflow and run your own custom
kubectl
command in the gitlab ci