Skip to content

Commit

Permalink
tofu init
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaguilar committed Oct 6, 2023
1 parent ec174bd commit 46625bf
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 149 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PKG ?= github.com/galleybytes/terraform-operator
PKG ?= github.com/galleybytes/tofu-kubed
DOCKER_REPO ?= ghcr.io/galleybytes
IMAGE_NAME ?= terraform-operator
DEPLOYMENT ?= ${IMAGE_NAME}
Expand Down Expand Up @@ -83,7 +83,7 @@ generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

openapi-gen: openapi-gen-bin
$(OPENAPI_GEN) --logtostderr=true -o "" -i github.com/galleybytes/terraform-operator/pkg/apis/tf/v1beta1 -O zz_generated.openapi -p pkg/apis/tf/v1beta1 -h ./hack/boilerplate.go.txt -r "-"
$(OPENAPI_GEN) --logtostderr=true -o "" -i github.com/galleybytes/tofu-kubed/pkg/apis/tf/v1beta1 -O zz_generated.openapi -p pkg/apis/tf/v1beta1 -h ./hack/boilerplate.go.txt -r "-"

docs:
/bin/bash hack/docs.sh ${VERSION}
Expand Down
71 changes: 10 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,23 @@
# Terraform Operator
# Tofu Kubed

> A Kubernetes CRD and Controller to handle Terraform operations by generating k8s pods catered to perform Terraform workflows
> A Kubernetes CRD and Controller to handle Tofu operations by generating k8s pods catered to perform Tofu workflows
<p align="center">
<img src="https://s3.amazonaws.com/classic.isaaguilar.com/tfo-worm-logo-text.png" alt="Terraform Operator Logo"></img>
</p>

## WIP

## What is terraform-operator?
This repo is a fork of [terraform-operator](https://github.com/galleybytes/terraform-operator) and is still a work in progress

## What is tofu-kubed?

This project is:

- A way to run Terraform in Kubernetes by defining Terraform deployments as Kubernetes manifests
- A controller that configures and starts [Terraform Workflows](http://tf.galleybytes.com/docs/architecture/workflow/) when it sees changes to the Kubernetes manifest
- Workflow runner pods that execute Terraform plan/apply and other user-defined scripts
- A way to run Tofu in Kubernetes by defining Tofu deployments as Kubernetes manifests
- A controller that configures and starts [Tofu Workflows](http://tf.galleybytes.com/docs/architecture/workflow/) when it sees changes to the Kubernetes manifest
- Workflow runner pods that execute Tofu plan/apply and other user-defined scripts

This project is not:

- An HCL to YAML converter or vice versa
- A Terraform Module or Registry

## Installation

The preferred method is to use helm. See [Install using Helm](http://tf.galleybytes.com/docs/getting-started/installation/#install-using-helm) on the docs.

Another simple method is to install the resources under `deploy` & `deploy/crds`

```bash
git clone https://github.com/galleybytes/terraform-operator.git
cd terraform-operator
kubectl apply -f deploy/bundles/v0.14.0/v0.14.0.yaml
```

See [more installation options](http://tf.galleybytes.com/docs/getting-started/installation/).

## Docs

Visit [http://tf.galleybytes.com](http://tf.galleybytes.com) to read the docs.

<p align="center">
<img src="https://s3.amazonaws.com/classic.isaaguilar.com/tfo-workflow-diagramv2.png" alt="Terraform Operator Workflow Diagram"></img>
</p>


## Related Projects and Tools

Here are some other projects that enhance the experience of Terraform Operator.


### Debug With `tfo` CLI

Terraform is great, but every now and then, a module takes a turn for the worse and the workflow fails. When this happens, a terraform workflow will need to be "debugged."

Fortunately, the `tfo` cli (https://github.com/isaaguilar/terraform-operator-cli) can be used to start a debug pod which is connected directly to the same terraform session the workflow runs. It does so by reading the TFO resource and generates a pod with the same environment vars, ConfigMaps, Secrets, and ServiceAccount as a regular workflow pod. Then it drops the user in a shell directly in the main module.

```bash
tfo debug my-tfo-resource --namespace default
```

The user should be ready to rock-n-roll and show off their mad debugging skills.

```bash
Connecting to my-tfo-resource-ca6ajn94-v2-debug-qmjd5.....

Try running 'terraform init'

/home/tfo-runner/generations/2/main$
```

Happy debugging!
- A Tofu Module or Registry


## Join the Community
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ENTRYPOINT ["/usr/local/bin/entrypoint"]
USER ${USER_UID}
# install operator binary is the only layer that changes
COPY _output/manager ${OPERATOR}
LABEL org.opencontainers.image.source https://github.com/galleybytes/terraform-operator
LABEL org.opencontainers.image.source https://github.com/galleybytes/tofu-kubed
4 changes: 2 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
"github.com/galleybytes/terraform-operator/pkg/apis"
"github.com/galleybytes/terraform-operator/pkg/controllers"
"github.com/galleybytes/tofu-kubed/pkg/apis"
"github.com/galleybytes/tofu-kubed/pkg/controllers"
localcache "github.com/patrickmn/go-cache"
"go.uber.org/zap/zapcore"
corev1 "k8s.io/api/core/v1"
Expand Down
3 changes: 2 additions & 1 deletion deploy/crds/tf.galleybytes.com_terraforms_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: terraforms.tf.galleybytes.com
spec:
group: tf.galleybytes.com
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/galleybytes/terraform-operator
module github.com/galleybytes/tofu-kubed

replace github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 // Required by Helm

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/addtoscheme_tf_v1beta1.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package apis

import (
"github.com/galleybytes/terraform-operator/pkg/apis/tf/v1beta1"
"github.com/galleybytes/tofu-kubed/pkg/apis/tf/v1beta1"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/tf/v1beta1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"k8s.io/kube-openapi/pkg/validation/spec"
)

var pkgpath = "github.com/galleybytes/terraform-operator/pkg/apis/tf/v1beta1"
var pkgpath = "github.com/galleybytes/tofu-kubed/pkg/apis/tf/v1beta1"

// +kubebuilder:object:generate=false
type Definition struct {
Expand Down
Loading

0 comments on commit 46625bf

Please sign in to comment.