Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logs): implement logging retrieval #264

Merged
merged 16 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.11.4
KUSTOMIZE_VERSION ?= 3.8.8
CONTROLLER_TOOLS_VERSION ?= v0.14.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
16 changes: 12 additions & 4 deletions api/v1alpha1/terraformlayer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ type TerraformLayerRepository struct {

// TerraformLayerStatus defines the observed state of TerraformLayer
type TerraformLayerStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
State string `json:"state,omitempty"`
LastResult string `json:"lastResult,omitempty"`
LastRun string `json:"lastRun,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
State string `json:"state,omitempty"`
LastResult string `json:"lastResult,omitempty"`
LastRun TerraformLayerRun `json:"lastRun,omitempty"`
LatestRuns []TerraformLayerRun `json:"latestRuns,omitempty"`
}

type TerraformLayerRun struct {
Name string `json:"name,omitempty"`
Commit string `json:"commit,omitempty"`
Date metav1.Time `json:"date,omitempty"`
Action string `json:"action,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
21 changes: 14 additions & 7 deletions api/v1alpha1/terraformrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ import (

// TerraformRunSpec defines the desired state of TerraformRun
type TerraformRunSpec struct {
Action string `json:"action,omitempty"`
Layer TerraformRunLayer `json:"layer,omitempty"`
Action string `json:"action,omitempty"`
Artifact Artifact `json:"artifact,omitempty"`
Layer TerraformRunLayer `json:"layer,omitempty"`
}

type Artifact struct {
Run string `json:"run,omitempty"`
Attempt string `json:"attempt,omitempty"`
}

type TerraformRunLayer struct {
Expand All @@ -36,11 +42,12 @@ type TerraformRunLayer struct {

// TerraformRunStatus defines the observed state of TerraformRun
type TerraformRunStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
State string `json:"state,omitempty"`
Retries int `json:"retries"`
LastRun string `json:"lastRun,omitempty"`
RunnerPod string `json:"runnerPod,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
State string `json:"state,omitempty"`
Retries int `json:"retries"`
LastRun string `json:"lastRun,omitempty"`
RunnerPod string `json:"runnerPod,omitempty"`
PlanArtifact string `json:"planArtifact,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
41 changes: 40 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

18 changes: 18 additions & 0 deletions cmd/datastore/datastore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package datastore

import (
"github.com/padok-team/burrito/internal/burrito"
"github.com/spf13/cobra"
)

func BuildDatastoreCmd(app *burrito.App) *cobra.Command {
cmd := &cobra.Command{
Use: "runner",
Short: "cmd to use burrito's runner",
}
cmd.AddCommand(buildDatastoreStartCmd(app))
return cmd
}
23 changes: 23 additions & 0 deletions cmd/datastore/start.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package datastore

import (
"github.com/padok-team/burrito/internal/burrito"
"github.com/spf13/cobra"
)

func buildDatastoreStartCmd(app *burrito.App) *cobra.Command {
cmd := &cobra.Command{
Use: "start",
Short: "Start Burrito Datastore",
// Do not display usage on program error
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return app.StartRunner()
},
}
cmd.Flags().StringVar(&app.Config.Server.Addr, "addr", ":8080", "addr the datastore listens on")
return cmd
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package cmd

import (
"github.com/padok-team/burrito/cmd/controllers"
"github.com/padok-team/burrito/cmd/datastore"
"github.com/padok-team/burrito/cmd/runner"
"github.com/padok-team/burrito/cmd/server"
"github.com/padok-team/burrito/internal/burrito"
Expand Down Expand Up @@ -33,6 +34,7 @@ func buildBurritoCmd(app *burrito.App) *cobra.Command {
cmd.AddCommand(controllers.BuildControllersCmd(app))
cmd.AddCommand(runner.BuildRunnerCmd(app))
cmd.AddCommand(server.BuildServerCmd(app))
cmd.AddCommand(datastore.BuildDatastoreCmd(app))
cmd.AddCommand(buildVersionCmd())
return cmd
}
Empty file.
15 changes: 12 additions & 3 deletions deploy/charts/burrito/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ Tenant Namespaces
{{- $_ := set $config.controller "namespaces" (default $tenantNamespaces $config.controller.namespaces) }}

{{/*
Redis Hostname
Datastore Authorized Service Accounts
*/}}
{{- if .Values.redis.enabled }}
{{- $_ := set $config.redis "hostname" (printf "%s.%s" "burrito-redis" .Release.Namespace) }}
{{- $datastoreAuthorizedServiceAccounts := list }}
{{- range $tenant := .Values.tenants }}
{{- range $sa := $tenant.serviceAccounts }}
{{- $serviceAccount := printf "%s/%s" $tenant.namespace.name $sa.name }}
{{- $datastoreAuthorizedServiceAccounts = append $datastoreAuthorizedServiceAccounts $serviceAccount }}
{{- end }}
{{- end }}
{{- $controller := printf "%s/%s" .Release.Namespace "burrito-controller" }}
{{- $datastoreAuthorizedServiceAccounts = append $datastoreAuthorizedServiceAccounts $controller }}
{{- $server := printf "%s/%s" .Release.Namespace "burrito-server" }}
{{- $datastoreAuthorizedServiceAccounts = append $datastoreAuthorizedServiceAccounts $server }}
{{- $_ := set $config.datastore "serviceAccounts" $datastoreAuthorizedServiceAccounts }}

apiVersion: v1
kind: ConfigMap
Expand Down
6 changes: 4 additions & 2 deletions deploy/charts/burrito/templates/controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ apiVersion: v1
kind: Service
metadata:
name: burrito-controllers
{{- with mergeOverwrite (deepCopy .metadata) .serviceAccount.metadata }}
labels:
{{- toYaml .metadata.labels | nindent 4}}
{{- toYaml .labels | nindent 4}}
annotations:
{{- toYaml .metadata.annotations | nindent 4}}
{{- toYaml .annotations | nindent 4}}
{{- end }}
spec:
type: {{ .type }}
ports:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{- if .Values.redis.enabled }}
{{- with mergeOverwrite (deepCopy .Values.global) .Values.redis }}
{{ $configChecksum := (include (print $.Template.BasePath "/config.yaml") . | sha256sum) }}

{{- with mergeOverwrite (deepCopy .Values.global) .Values.datastore }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: burrito-redis
name: burrito-datastore
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
labels:
Expand All @@ -18,6 +19,7 @@ spec:
template:
metadata:
annotations:
checksum/burrito-config: {{ $configChecksum }}
{{- toYaml .deployment.podAnnotations | nindent 8 }}
labels:
{{- toYaml .metadata.labels | nindent 8 }}
Expand All @@ -26,18 +28,18 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: burrito-redis
serviceAccountName: burrito-datastore
securityContext:
{{- toYaml .deployment.podSecurityContext | nindent 8 }}
containers:
- name: redis
- name: burrito
command:
{{- toYaml .deployment.command | nindent 12 }}
args:
{{- toYaml .deployment.args | nindent 12 }}
securityContext:
{{- toYaml .deployment.securityContext | nindent 12 }}
image: "{{ .deployment.image.repository }}:{{ .deployment.image.tag }}"
image: "{{ .deployment.image.repository }}:{{ .deployment.image.tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ .deployment.image.pullPolicy }}
ports:
{{- toYaml .deployment.ports | nindent 12 }}
Expand All @@ -51,6 +53,10 @@ spec:
{{- toYaml .deployment.env | nindent 12 }}
envFrom:
{{- toYaml .deployment.envFrom | nindent 12 }}
volumeMounts:
- name: burrito-config
mountPath: /etc/burrito
readOnly: true
{{- with .deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -63,16 +69,22 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: burrito-config
configMap:
name: burrito-config
{{- if .service.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: burrito-redis
name: burrito-datastore
{{- with mergeOverwrite (deepCopy .metadata) .serviceAccount.metadata }}
labels:
{{- toYaml .metadata.labels | nindent 4}}
{{- toYaml .labels | nindent 4}}
annotations:
{{- toYaml .metadata.annotations | nindent 4}}
{{- toYaml .annotations | nindent 4}}
{{- end }}
spec:
type: {{ .type }}
ports:
Expand All @@ -84,27 +96,26 @@ spec:
apiVersion: v1
kind: ServiceAccount
metadata:
name: burrito-redis
name: burrito-datastore
labels:
{{- toYaml .metadata.labels | nindent 4 }}
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
kind: ClusterRoleBinding
metadata:
name: burrito-redis
name: burrito-datastore
labels:
{{- toYaml .metadata.labels | nindent 4 }}
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: burrito-redis
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: burrito-redis
name: burrito-datastore
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- end }}
Loading
Loading