Skip to content

RichardSouzza/Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Useful Scripts for Servers

Setup

  1. Copy setup script for server:
scp ./setup.sh root@<ip>:/root/
  1. Allow script execution:
chmod +x setup.sh
  1. And run:
./setup.sh

About K3s

Just adapt inventory.yml to something like this:

k3s_cluster:
  children:
    server:
      hosts:
        almalinux:
          ansible_host: <ip>
          ansible_user: ansible
          ansible_become: yes
          ansible_become_method: sudo
          ansible_become_user: root
          ansible_ssh_private_key_file: ~/.ssh/id_ansible

  vars:
    k3s_version: v1.31.12+k3s1
    opt_tls_san:
      - <ip>
      - <domain>

And then:

ansible-playbook playbooks/site.yml -i inventory.yml --ask-become-pass

Helm installation

Simple run the playbook:

ansible-playbook playbooks/helm.yaml --ask-become-pass
  1. Add the Drone Helm Chart repository:
helm repo add drone https://charts.drone.io
helm repo update
  1. Go to GitHub Settings -> Developer Settings -> OAuth Apps -> New OAuth App.

  2. In the form, Homepage URL must match the server IP http://drone.<domain> and the callback to the login route http://drone.<domain>/login.

  3. Set Drone secrets on the server:

kubectl create secret generic drone-secrets \
  --namespace drone \
  --from-literal=DRONE_RPC_SECRET=$(openssl rand -hex 16) \
  --from-literal=DRONE_CONFIG_SECRET=$(openssl rand -hex 16) \
  --from-literal=DRONE_GITHUB_CLIENT_ID=<drone_client_id> \
  --from-literal=DRONE_GITHUB_CLIENT_SECRET=<drone_client_secret>

Drone Server

  1. Download the chart:
helm pull drone/drone --untar
  1. Set Drone configurations:
cat <<-EOF > ./drone-values.yaml
ingress:
  enabled: true
  hosts:
    - host: drone.<domain>
      paths:
        - path: /
          pathType: ImplementationSpecific

env:
  DRONE_SERVER_HOST: "drone.<domain>"
  DRONE_SERVER_PROTO: "http"

extraSecretNamesForEnvFrom:
  - drone-secrets
EOF
  1. Install Drone Server:
kubectl create namespace drone
helm install drone drone/drone \
  --namespace drone \
  --values drone-values.yaml
  1. When necessary to update:
helm upgrade drone drone/drone \
  --namespace drone \
  --values drone-values.yaml

Drone Docker Runner

  1. Download the chart:
helm pull drone/drone-runner-docker --untar
  1. Set Drone configurations
cat <<-EOF > ./drone-values.yaml
env:
  DRONE_RPC_PROTO: "http"
  DRONE_RPC_HOST: "drone.<domain>"
  DRONE_RUNNER_NAME: "docker-runner"

extraSecretNamesForEnvFrom:
  - drone-secrets
EOF
  1. Install Drone Docker Runner:
helm install drone-runner-docker drone/drone-runner-docker \
  --namespace drone \
  --values drone-values.yaml
  1. When necessary to update:
helm upgrade drone-runner-docker drone/drone-runner-docker \
  --namespace drone \
  --values drone-values.yaml
  1. Go to GitHub Settings -> Developer Settings -> Personal access tokens -> Tokens (classic) -> Generate new token (classic)

  2. Select scopes "repo" and "read:packages".

  3. Set Container Registry access secrets:

sudo kubectl create secret docker-registry ghcr-secrets \
  --docker-server=ghcr.io \
  --docker-username=<username> \
  --docker-password=<accessToken> \
  -n drone

About

Useful docs and scripts for server configuration.

Resources

License

Stars

Watchers

Forks

Languages