Skip to main content

Install light-agent in Kubernetes

Push Images to Kubernetes Registry

Execute the following operations on the machine where Lighthouse is installed

Note

If using a private registry, please perform the following operations to edit /etc/docker/daemon.json file, add:

{
"insecure-registries" : ["<registry_url>"]
}

After modification, execute the following command to restart Docker

systemctl restart docker

Push Images

cd /opt/lighthouse/downloads   #/opt/lighthouse is the directory where Lighthouse platform is located
# Note: Please replace the registry address (need to add project name, e.g., 192.168.2.99/light-agent); if username and password are required, add -u and -p parameters
REGISTRY_REPO=your_docker_registry_url ./image-pusher.sh -- -u <username> -p <password>

Deploy light-agent

Execute the following operations in the Kubernetes environment to deploy light-agent

Get Kubernetes Deployment Script Template light-agent-template.yaml

curl -O http://<Lighthouse IP>/downloads/k8s/light-agent-template.yaml

Get Docker Configuration Secret

  1. Create Secret
Note
  • --docker-email: Please replace with your email
  • --docker-username: Please replace with your username
  • --docker-password: Please replace with your password
  • --docker-server: Please replace with your registry address (no need to add project name, e.g., 192.168.2.99)
kubectl create secret docker-registry dockerconfig-secret \
--docker-email=<email> \
--docker-username=<username> \
--docker-password=<password> \
--docker-server=<registry_url>
  1. Get Secret
kubectl get secret dockerconfig-secret -o jsonpath='{.data.*}'

The execution result will be like:

eyJhdXRocyI6eyIxOTIuMTY4LjIuOTkiOnsidXNlcm5hbWUiOiJjaGVuZ3Vvd2VpIiwicGFzc3dvcmQiOiJTZWN2aXNpb24xMjMiLCJlbWFpbCI6ImNoZW5ndW93ZWlAdmFsaWRhdGlvbnMuY24iLCJhdXRoIjoiWTJobGJtZDFiM2RsYVRwVFpXTjJhWE5wYjI0eE1qTT0ifX19

Use envsubst to Generate light-agent.yaml File

Note
  • COLLECTOR_SERVER_IP: Please replace with Lighthouse IP address
  • REGISTRY_REPO: Please replace with your specific registry address (need to add project name, e.g., 192.168.2.99/light-agent)
  • REGISTRY_CRED: Please replace with the dockerconfig-secret obtained in the previous step
  • envsubst: Environment variable replacement tool. Variables contained within do not need to be modified
COLLECTOR_SERVER_IP=<Lighthouse IP> REGISTRY_REPO=<your_docker_registry_url> REGISTRY_CRED=<registry_crea_str> envsubst '${REGISTRY_REPO} ${COLLECTOR_SERVER_IP} ${REGISTRY_CRED}' <light-agent-template.yaml >light-agent.yaml

Execute Installation

kubectl apply -f light-agent.yaml

Check Status

watch -n 1 kubectl get all -n light-agent

Uninstall light-agent

kubectl delete -f light-agent.yaml