Installer for Harness SMP
- AWS: Supports EKS with ALB
Profile | Resources | Description |
---|---|---|
small | 5 t2.2xlarge nodes | Supports 50 users with 10 concurrent executions |
pov | 2 t2.2xlarge nodes | Supports 5 users with 1 execution at a time |
Feature | Description | Supported Platform |
---|---|---|
loadbalancer | Creates loadbalancer | AWS (ALB) |
kubernetes cluster | Creates kubernetes cluster with desired node config | AWS (EKS) |
vpc | Creates VPC | AWS |
airgap | Creates egress rules to block outgoing traffic | AWS |
tls | Create self signed certificate | AWS |
helm chart | Install harness helm chart with existing overrides | AWS |
dns | Create hosted zone for existing domain | AWS (Route53) |
monitoring | Install prometheus and grafana helm charts | AWS (EKS) |
- Make sure you have
tofu
installed. You can check (official documentation)[https://opentofu.org/docs/intro/install/] on how to install opentofu.
- Clone this repository
- Run the binary with the following command
go build -o smp-installer github.com/harness/smp-installer/cmd
- Use the example.yaml as your configuration reference for the tool
- Update the necessary fields as required
- Authenticate with AWS
- Go to AWS IAM Console
- Copy the access key and secret key of the user which has admin access to the AWS project
- Export the keys in your terminal
- Run the sync command
./smp-installer sync -c ./example.yaml
- The tool will generate the output directory configured in
example.yaml
which will store all rendered tofu files.
├── LICENSE
├── README.md
├── cmd : contains the entrypoint for the installer
│ ├── main.go : chains the individual commands
│ └── resources : contains individual resource command
│ ├── harness.go
│ ├── kubernetes.go
│ ├── loadbalancer.go
│ └── resource.go
├── example.yaml : sample file to test the installer
├── pkg : contains internal logic
│ ├── client : contains individual resource client. Each client manages the resource creation
│ │ ├── client.go
│ │ ├── helm.go
│ │ ├── kubernetes.go
│ │ └── loadbalancer.go
│ ├── render : Contains template logic
│ │ └── template.go
│ ├── store : Contains data store to store config and runtime output from clients
│ │ ├── memory.go
│ │ ├── memory_test.go
│ │ └── store.go
│ └── tofu : Contains tofu files for all supported clouds
│ ├── aws
│ │ ├── harness : Harness helm chart tofu module
│ │ │ ├── harness.tf
│ │ │ ├── tf.vars
│ │ │ └── variables.tf
│ │ ├── kubernetes : Kubernetes cluster tofu module
│ │ │ ├── kubernetes.tf
│ │ │ ├── tf.vars
│ │ │ ├── variables.tf
│ │ │ └── vpc.tf
│ │ └── loadbalancer : Load balancer tofu module
│ │ ├── loadbalancer.tf
│ │ ├── tf.vars
│ │ └── variables.tf
│ ├── files.go : Utility to load above files
│ └── helper.go : Tofu helper methods
├── profiles : Contains supported profile overrides
│ ├── files.go
│ └── small
│ └── override.yaml
│ └── config.yaml
│ └── pov
│ └── override.yaml
│ └── config.yaml
Adding a new resource requires changes atleast in 3 below places
- cmd/resources/.go
- pkg/client/.go
- pkg/tofu/aws//*
Adding a new resource command requires a new file at cmd/resources/<newresource>.go
.
The new command type must implement the Resource
interface and implement the below two methods.
Name()
: This method returns the name of the resourceSync()
: This method orchestrates the resource lifecylce using resource client
Adding a new resource client requires a new file at pkg/client/<newresource>.go
The new client must implement the Client
interface and implement the below methods.
PreExec()
: This method is invoked to prepare the environment before invokingtofu
. This can be used to change values in some file, add data for.Self
object to be used for rendering etc.Exec()
: This method is called to invoke the tofu command. Client can use this method to check for existing tofu state, invoke tofu command, or run some other operations.PostExec()
: This method is called to do cleanups. This method is expected to return the output for this resource which is used to populate the.Output
object
Adding a new tofu module requires adding the module at pkg/tofu/<cloud>/<newresource>
. The tofu module must have tofu files and a var file named tf.vars
which is either templatized or hardcoded.
All tofu files and profile overrides can be templated.
Installer provides below built-in objects to be used in the templates.
-
.Config
: This object can be used to refer to values coming from installer's config file such as example.yaml.Example: {{ .Config.kubernetes.version }}
-
.Ouput
: This object can be used to refer to output exposed by any resource client. For example, profile override can refer to loadbalancer IP like.Output.loadbalancer.ip
if loadbalancer client exposes the output. -
.Self
: This object can be used to refer to data exposed by a client during itsPreExec
hook.