Skip to content

Commit

Permalink
GCP Storage support for logs, terraform state and modules (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfespa17 authored Jun 25, 2022
1 parent a665a93 commit bcb8599
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ sample-values.yaml
sample-values-post.yaml
sample-values-mysql.yaml
sample-values-dev365.yaml
sample-values-dev365-aws.yaml
sample-values-dev365-aws.yaml
sample-values-dev365-gcp.yaml
152 changes: 140 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ Terrakube require an Aws S3 to save the state/output for the jobs and to save th

To create the Aws S3 you can use the following [terraform module]() (Work in Progress).

#### 3.2 GCP Storage

Terrakube require an Storage bucket to save the state/output for the jobs and to save the terraform modules when using terraform CLI.

To create the Gcp Storage you can use the following [terraform module]() (Work in Progress).

### 4. Build Yaml file

Once you have completed the above steps you can complete the file values.yaml to deploy the helm chart, you can check the following examples:
Expand Down Expand Up @@ -107,7 +113,7 @@ storage:
## API properties
api:
enabled: true
version: "2.4.1"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
Expand All @@ -127,7 +133,7 @@ api:
## Executor properties
executor:
enabled: true
version: "1.7.2"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
Expand All @@ -146,7 +152,7 @@ executor:
## Registry properties
registry:
enabled: true
version: "2.4.1"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
Expand All @@ -160,7 +166,7 @@ registry:
## UI Properties
ui:
enabled: true
version: "0.7.4"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources:
Expand Down Expand Up @@ -230,7 +236,7 @@ storage:
## API properties
api:
enabled: true
version: "2.4.1"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
Expand All @@ -250,7 +256,7 @@ api:
## Executor properties
executor:
enabled: true
version: "1.7.2"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
Expand All @@ -269,7 +275,129 @@ executor:
## Registry properties
registry:
enabled: true
version: "2.4.1"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
limits:
cpu: 500m
memory: 1024Mi
requests:
cpu: 200m
memory: 256Mi

## UI Properties
ui:
enabled: true
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 200m
memory: 256Mi

## Ingress properties
ingress:
useTls: true
ui:
enabled: true
domain: "ui.terrakube.docker.internal" # Replace with the real value
path: "/(.*)" # Replace with the real value
pathType: "Prefix" # Replace with the real value
annotations: # This annotations can change based on requirements. The followin is an example using nginx ingress and lets encrypt
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
cert-manager.io/cluster-issuer: letsencrypt
api:
enabled: true
domain: "api.terrakube.docker.internal" # Replace with the real value
path: "/(.*)" # Replace with the real value
pathType: "Prefix" # Replace with the real value
annotations: # This annotations can change based on requirements. The followin is an example using nginx ingress and lets encrypt
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/configuration-snippet: "proxy_set_header Authorization $http_authorization;"
cert-manager.io/cluster-issuer: letsencrypt
registry:
enabled: true
domain: "registry.terrakube.docker.internal" # Replace with the real value
path: "/(.*)" # Replace with the real value
pathType: "Prefix" # Replace with the real value
annotations: # This annotations can change based on requirements. The followin is an example using nginx ingress and lets encrypt
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
cert-manager.io/cluster-issuer: letsencrypt
```
***Example using Nginx Ingress and Gcp Storage:***
```yaml
## Global Name
name: "terrakube"

## Azure Active Directory Security
security:
type: "AZURE" # This is the only value supported righ now
azure:
appIdURI: "XXX" #Replace with values from Step 1
appClientId: "XXX"
appTenantId: "XXX"
appSecret: "XXX"

## Terraform Storage
storage:
gcp:
projectId: "XXXX"
bucketName: "XXX"
credentials: "XXX" #<==JSON CREDENTIAL IN BASE64 ENCODING

## API properties
api:
enabled: true
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
limits:
cpu: 500m
memory: 1024Mi
requests:
cpu: 200m
memory: 256Mi
properties:
databaseType: "SQL_AZURE" # Replace with "H2" (ONLY FOR TESTING), "SQL_AZURE", "POSTGRESQL" or "MYSQL"
databaseHostname: "mysuperdatabse.database.windows.net" # Replace with the real value
databaseName: "databasename" # Replace with the real value
databaseUser: "databaseuser" # Replace with the real value
databasePassword: "XXX" # Replace with the real value

## Executor properties
executor:
enabled: true
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 500m
memory: 256Mi
properties:
toolsRepository: "https://github.com/AzBuilder/terrakube-extensions" # Default extension repository
toolsBranch: "main" #Default branch for extensions
terraformStateType: "GcpTerraformStateImpl"
terraformOutputType: "GcpTerraformOutputImpl"

## Registry properties
registry:
enabled: true
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources: #Optional
Expand All @@ -283,7 +411,7 @@ registry:
## UI Properties
ui:
enabled: true
version: "0.7.4"
version: "2.5.0"
replicaCount: "1"
serviceType: "ClusterIP"
resources:
Expand Down Expand Up @@ -362,7 +490,7 @@ storage:
## API properties
api:
enabled: true
version: "2.4.1"
version: "2.5.0"
replicaCount: "1"
serviceType: "NodePort"
resources: #Optional
Expand All @@ -382,7 +510,7 @@ api:
## Executor properties
executor:
enabled: true
version: "1.7.2"
version: "2.5.0"
replicaCount: "1"
serviceType: "NodePort"
resources: #Optional
Expand All @@ -401,7 +529,7 @@ executor:
## Registry properties
registry:
enabled: true
version: "2.4.1"
version: "2.5.0"
replicaCount: "1"
serviceType: "NodePort"
resources: #Optional
Expand All @@ -415,7 +543,7 @@ registry:
## UI Properties
ui:
enabled: true
version: "0.7.4"
version: "2.5.0"
replicaCount: "1"
serviceType: "NodePort"
resources:
Expand Down
8 changes: 8 additions & 0 deletions templates/secrets-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ stringData:
AwsStorageBucketName: '{{ .Values.storage.aws.bucketName }}'
AwsStorageRegion: '{{ .Values.storage.aws.region }}'
{{- end }}

{{- if and (.Values.storage.gcp).projectId (.Values.storage.gcp).bucketName (.Values.storage.gcp).credentials }}
#GCP Storage Bucket
StorageType: 'GCP'
GcpStorageProjectId: '{{ .Values.storage.gcp.projectId }}'
GcpStorageBucketName: '{{ .Values.storage.gcp.bucketName }}'
GcpStorageCredentialsBase64: '{{ .Values.storage.gcp.credentials }}'
{{- end }}
{{ end }}
14 changes: 14 additions & 0 deletions templates/secrets-executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ stringData:
AwsTerraformOutputBucketName: '{{ .Values.storage.aws.bucketName }}'
AwsTerraformOutputRegion: '{{ .Values.storage.aws.region }}'
{{- end }}

{{- if eq .Values.executor.properties.terraformStateType "GcpTerraformStateImpl" }}
#GCP Bucket State
GcpTerraformStateProjectId: '{{ .Values.storage.gcp.projectId }}'
GcpTerraformStateBucketName: '{{ .Values.storage.gcp.bucketName }}'
GcpTerraformStateCredentials: '{{ .Values.storage.gcp.credentials }}'
{{- end }}

{{- if eq .Values.executor.properties.terraformOutputType "GcpTerraformOutputImpl" }}
#GCP Bucket Output
GcpTerraformOutputProjectId: '{{ .Values.storage.gcp.projectId }}'
GcpTerraformOutputBucketName: '{{ .Values.storage.gcp.bucketName }}'
GcpTerraformOutputCredentials: '{{ .Values.storage.gcp.credentials }}'
{{- end }}
{{ end }}
8 changes: 8 additions & 0 deletions templates/secrets-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ stringData:
AwsStorageBucketName: '{{ .Values.storage.aws.bucketName }}'
AwsStorageRegion: '{{ .Values.storage.aws.region }}'
{{- end }}

{{- if and (.Values.storage.gcp).projectId (.Values.storage.gcp).bucketName (.Values.storage.gcp).credentials }}
#Gcp Storage
RegistryStorageType: 'GcpStorageImpl'
GcpStorageProjectId: '{{ .Values.storage.gcp.projectId }}'
GcpStorageBucketName: '{{ .Values.storage.gcp.bucketName }}'
GcpStorageCredentialsBase64: '{{ .Values.storage.gcp.credentials }}'
{{- end }}
{{ end }}
22 changes: 20 additions & 2 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@
"type": "string"
}
}
},
"gcp": {
"type": "object",
"required": ["projectId", "bucketName", "credentials"],
"properties": {
"projectId": {
"description": "GCP Project Id",
"type": "string"
},
"bucketName": {
"description": "GCP Storage Bucket Name",
"type": "string"
},
"credentials": {
"description": "GCP Credentials JSON in Base64 encoding",
"type": "string"
}
}
}
}
},
Expand Down Expand Up @@ -170,11 +188,11 @@
},
"terraformStateType": {
"description": "Terraform State implementation",
"enum": ["AzureTerraformStateImpl", "AwsTerraformStateImpl"]
"enum": ["AzureTerraformStateImpl", "AwsTerraformStateImpl", "GcpTerraformStateImpl"]
},
"terraformOutputType": {
"description": "Terraform Output implementation",
"enum": ["AzureTerraformOutputImpl", "AwsTerraformOutputImpl"]
"enum": ["AzureTerraformOutputImpl", "AwsTerraformOutputImpl", "GcpTerraformOutputImpl"]
}
}
}
Expand Down

0 comments on commit bcb8599

Please sign in to comment.