Skip to content

Commit

Permalink
Merge branch 'main' into k8s_122
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Jan 18, 2022
2 parents 740193f + 812e59d commit cf04cf4
Show file tree
Hide file tree
Showing 60 changed files with 2,383 additions and 2,680 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Lagoon KBD Test
name: Lagoon Remote Controller Test

on:
push:
branches:
- main
- re-namespace
pull_request:
branches:
- main
Expand All @@ -22,15 +23,16 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Install kustomize, kubebuilder, helm
- name: Install kustomize, kubebuilder, helm, docker-compose, kind
run: |
#kustomize
curl -sLo /tmp/kustomize_v3.5.4_linux_amd64.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.5.4/kustomize_v3.5.4_linux_amd64.tar.gz
sudo tar -C /usr/local/bin -xzf /tmp/kustomize_v3.5.4_linux_amd64.tar.gz
#kubebuilder
curl -sL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64 /usr/local/kubebuilder
echo "/usr/local/kubebuilder/bin" >> $GITHUB_PATH
sudo mkdir -p /usr/local/kubebuilder/bin
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64/bin/* /usr/local/kubebuilder/bin
chmod +x /usr/local/kubebuilder/bin/*
#helm
curl -sL https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/linux-amd64/helm /usr/local/bin/helm
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
domain: amazee.io
repo: github.com/amazeeio/lagoon-kbd
repo: github.com/uselagoon/remote-controller
resources:
- group: lagoon
kind: LagoonBuild
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ There is currently no documentation for how to do this, we may release more info
Using [Helm 3](https://helm.sh/docs/intro/install/)

```
helm repo add lagoon-builddeploy https://raw.githubusercontent.com/amazeeio/lagoon-kbd/main/charts
helm repo add lagoon-builddeploy https://raw.githubusercontent.com/uselagoon/remote-controller/main/charts
## with rabbitmq support for communicating with a lagoon messaging queue
helm upgrade --install -n lagoon-builddeploy lagoon-builddeploy lagoon-builddeploy/lagoon-builddeploy \
Expand All @@ -49,7 +49,7 @@ You will need to install any prerequisites for kubebuilder [see here](https://bo
# install any requirements
make install
# deploy the actual handler
make IMG=amazeeio/lagoon-builddeploy:latest deploy
make IMG=uselagoon/remote-controller:latest deploy
```

## LagoonBuild Spec
Expand All @@ -62,7 +62,7 @@ metadata:
spec:
build:
ci: 'false' # this is a string, not a bool
image: amazeeio/kubectl-build-deploy-dind:v1.8.1
image: uselagoon/kubectl-build-deploy-dind:v1.8.1
type: branch
gitReference: origin/main
openshift: false
Expand Down
40 changes: 24 additions & 16 deletions api/v1alpha1/lagoonbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// JobConditionType const for the status type
type JobConditionType string
// BuildStatusType const for the status type
type BuildStatusType string

// These are valid conditions of a job.
const (
// BuildComplete means the build has completed its execution.
JobComplete JobConditionType = "Complete"
// BuildFailed means the job has failed its execution.
JobFailed JobConditionType = "Failed"
// BuildFailed means the job has failed its execution.
JobCancelled JobConditionType = "Cancelled"
// BuildStatusRunning means the build is pending.
BuildStatusPending BuildStatusType = "Pending"
// BuildStatusRunning means the build is running.
BuildStatusRunning BuildStatusType = "Running"
// BuildStatusComplete means the build has completed its execution.
BuildStatusComplete BuildStatusType = "Complete"
// BuildStatusFailed means the job has failed its execution.
BuildStatusFailed BuildStatusType = "Failed"
// BuildStatusCancelled means the job been cancelled.
BuildStatusCancelled BuildStatusType = "Cancelled"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand All @@ -57,15 +61,15 @@ type LagoonBuildSpec struct {
type LagoonBuildStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Conditions []LagoonConditions `json:"conditions,omitempty"`
Log []byte `json:"log,omitempty"`
Conditions []LagoonBuildConditions `json:"conditions,omitempty"`
Log []byte `json:"log,omitempty"`
}

// LagoonConditions defines the observed conditions of the pods.
type LagoonConditions struct {
// LagoonBuildConditions defines the observed conditions of build pods.
type LagoonBuildConditions struct {
LastTransitionTime string `json:"lastTransitionTime"`
Status corev1.ConditionStatus `json:"status"`
Type JobConditionType `json:"type"`
Type BuildStatusType `json:"type"`
// Condition string `json:"condition"`
}

Expand Down Expand Up @@ -96,9 +100,11 @@ func init() {

// Build contains the type of build, and the image to use for the builder.
type Build struct {
CI string `json:"ci,omitempty"`
Image string `json:"image,omitempty"`
Type string `json:"type"`
CI string `json:"ci,omitempty"`
Image string `json:"image,omitempty"`
Type string `json:"type"`
Priority *int `json:"priority,omitempty"`
BulkID string `json:"bulkId,omitempty"`
}

// Project contains the project information from lagoon.
Expand All @@ -121,6 +127,8 @@ type Project struct {
Monitoring Monitoring `json:"monitoring"`
Variables Variables `json:"variables"`
Registry string `json:"registry,omitempty"`
EnvironmentIdling *int `json:"environmentIdling,omitempty"`
ProjectIdling *int `json:"projectIdling,omitempty"`
}

// Variables contains the project and environment variables from lagoon.
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/lagoonmessaging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type LagoonLogMeta struct {
Task *LagoonTaskInfo `json:"task,omitempty"`
Key string `json:"key,omitempty"`
AdvancedData string `json:"advancedData,omitempty"`
Cluster string `json:"clusterName,omitempty"`
}

// LagoonMessage is used for sending build info back to Lagoon
Expand Down
41 changes: 39 additions & 2 deletions api/v1alpha1/lagoontask_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,41 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// TaskStatusType const for the status type
type TaskStatusType string

// These are valid conditions of a job.
const (
// TaskStatusRunning means the build is pending.
TaskStatusPending TaskStatusType = "Pending"
// TaskStatusRunning means the build is running.
TaskStatusRunning TaskStatusType = "Running"
// TaskStatusComplete means the build has completed its execution.
TaskStatusComplete TaskStatusType = "Complete"
// TaskStatusFailed means the job has failed its execution.
TaskStatusFailed TaskStatusType = "Failed"
// TaskStatusCancelled means the job been cancelled.
TaskStatusCancelled TaskStatusType = "Cancelled"
)

// TaskType const for the status type
type TaskType string

// These are valid conditions of a job.
const (
// TaskStatusRunning means the build is pending.
TaskTypeStandard TaskType = "standard"
// TaskStatusRunning means the build is running.
TaskTypeAdvanced TaskType = "advanced"
)

// LagoonTaskSpec defines the desired state of LagoonTask
type LagoonTaskSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Expand Down Expand Up @@ -85,8 +114,16 @@ type LagoonTaskEnvironment struct {
type LagoonTaskStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Conditions []LagoonConditions `json:"conditions,omitempty"`
Log []byte `json:"log,omitempty"`
Conditions []LagoonTaskConditions `json:"conditions,omitempty"`
Log []byte `json:"log,omitempty"`
}

// LagoonTaskConditions defines the observed conditions of task pods.
type LagoonTaskConditions struct {
LastTransitionTime string `json:"lastTransitionTime"`
Status corev1.ConditionStatus `json:"status"`
Type TaskStatusType `json:"type"`
// Condition string `json:"condition"`
}

// +kubebuilder:object:root=true
Expand Down
67 changes: 49 additions & 18 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build-push.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
REPO=${2:-amazeeio}
REPO=${2:-uselagoon}
TAG=${1:-latest}
IMGNAME=${3:-lagoon-builddeploy}
IMGNAME=${3:-remote-controller}
echo "Creating image for $REPO/${IMGNAME}:$TAG and pushing to docker hub"
make IMG=$REPO/${IMGNAME}:$TAG docker-build && make IMG=$REPO/${IMGNAME}:$TAG docker-push
Loading

0 comments on commit cf04cf4

Please sign in to comment.