-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
130 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: v1.0 | ||
name: Initial Pipeline | ||
agent: | ||
machine: | ||
type: e2-standard-2 | ||
os_image: ubuntu2004 | ||
blocks: | ||
- name: 'Lint' | ||
dependencies: [] | ||
task: | ||
jobs: | ||
- name: Lint | ||
commands: | ||
- sem-version go 1.21 | ||
- checkout | ||
- go install github.com/mgechev/revive@latest | ||
- make lint | ||
- name: "Security checks" | ||
dependencies: [] | ||
task: | ||
secrets: | ||
- name: security-toolbox-shared-read-access | ||
prologue: | ||
commands: | ||
- checkout | ||
- mv ~/.ssh/security-toolbox ~/.ssh/id_rsa | ||
- sudo chmod 600 ~/.ssh/id_rsa | ||
jobs: | ||
- name: Check dependencies | ||
commands: | ||
- make check.deps | ||
- name: Check code | ||
commands: | ||
- make check.static | ||
- name: Check docker | ||
commands: | ||
- make docker.build | ||
- make check.docker | ||
epilogue: | ||
always: | ||
commands: | ||
- 'if [ -f results.xml ]; then test-results publish --name="Security checks" results.xml; fi' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
FROM alpine:3.14 | ||
FROM ubuntu:22.04 | ||
|
||
ARG USERNAME=semaphore | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
# Create the user | ||
RUN groupadd --gid $USER_GID $USERNAME && \ | ||
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME | ||
|
||
COPY build/controller / | ||
|
||
USER $USERNAME | ||
WORKDIR /home/semaphore | ||
HEALTHCHECK NONE | ||
|
||
ENTRYPOINT ["/controller"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
### Testing locally | ||
# Semaphore agent controller for Kubernetes | ||
|
||
```bash | ||
# Create k8s cluster | ||
sem-version go 1.21 | ||
curl -sLO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && install minikube-linux-amd64 /tmp/ | ||
/tmp/minikube-linux-amd64 config set WantUpdateNotification false | ||
/tmp/minikube-linux-amd64 start --driver=docker | ||
eval $(/tmp/minikube-linux-amd64 docker-env) | ||
A Kubernetes controller that runs Semaphore jobs in Kubernetes. | ||
|
||
# Create required k8s resources | ||
kubectl apply -f resources.yml | ||
## Installation | ||
|
||
# Expose configuration parameters | ||
export SEMAPHORE_API_TOKEN=??? | ||
export SEMAPHORE_ENDPOINT=rtx.sxpreprod.com | ||
export KUBERNETES_NAMESPACE=default | ||
export SEMAPHORE_AGENT_IMAGE=semaphoreci/agent:v2.2.14 | ||
export KUBERNETES_SERVICE_ACCOUNT=semaphore-agent-svc-account | ||
export MAX_PARALLEL_JOBS=10 | ||
export SEMAPHORE_AGENT_STARTUP_PARAMETERS='--kubernetes-executor-pod-spec WHATEVER --pre-job-hook-path /opt/semaphore/agent/hooks/pre-job.sh --source-pre-job-hook' | ||
### Requirements | ||
|
||
# Build and start controller | ||
go build -o controller main.go | ||
./controller &>/tmp/controller.logs | ||
``` | ||
- A Kubernetes cluster | ||
- A Semaphore API token | ||
|
||
### Configuration | ||
|
||
| Environment variable | Description | | ||
|------------------------------------|-------------| | ||
| SEMAPHORE_API_TOKEN | The Semaphore API token used to inspect the job queues. | | ||
| SEMAPHORE_ENDPOINT | The Semaphore control plane endpoint, e.g. `<your-organization>.semaphoreci.com`. | | ||
| KUBERNETES_NAMESPACE | The Kubernetes namespace where the resources for Semaphore jobs will be created. By default, the default namespace is used. | | ||
| SEMAPHORE_AGENT_IMAGE | The [Semaphore agent](https://github.com/semaphoreci/agent) image to use when creating agents. By default, `semaphoreci/agent:latest`. | | ||
| MAX_PARALLEL_JOBS | The max number of Semaphore jobs to run in parallel. By default, 10. | | ||
| KUBERNETES_SERVICE_ACCOUNT | The Kubernetes service account to attach to the pods created for the [Semaphore agent](https://github.com/semaphoreci/agent). | | ||
| SEMAPHORE_AGENT_LABELS | A comma-separated list of Kubernetes labels to apply on all resources created by the controller. | | ||
| SEMAPHORE_AGENT_STARTUP_PARAMETERS | Any additional [Semaphore agent configuration parameters](https://docs.semaphoreci.com/ci-cd-environment/configure-self-hosted-agent/) to pass to the agents being created. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ignoreGeneratedHeader = false | ||
severity = "warning" | ||
confidence = 0.8 | ||
errorCode = 1 | ||
warningCode = 1 | ||
|
||
[rule.blank-imports] | ||
[rule.context-as-argument] | ||
[rule.context-keys-type] | ||
[rule.dot-imports] | ||
[rule.error-return] | ||
[rule.error-strings] | ||
[rule.error-naming] | ||
# [rule.exported] | ||
[rule.if-return] | ||
[rule.increment-decrement] | ||
[rule.var-naming] | ||
[rule.var-declaration] | ||
[rule.range] | ||
[rule.receiver-naming] | ||
[rule.time-naming] | ||
[rule.unexported-return] | ||
[rule.indent-error-flow] | ||
[rule.errorf] | ||
|
||
[rule.package-comments] | ||
Disabled = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.