Skip to content

Commit

Permalink
fix target group bindings and helm release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Singer committed Nov 16, 2023
1 parent e02fb4d commit b3c0f48
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 32 deletions.
9 changes: 0 additions & 9 deletions pkg/infra/iac3/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,6 @@ func (tc *TemplatesCompiler) getInputArgs(r *construct.Resource, template *Resou
case "aws:region", "aws:availability_zone", "aws:account_id":
continue

case "kubernetes:helm_chart":
ao := tc.NewAppliedOutput(construct.PropertyRef{
Resource: dep,
// ready: pulumi.Output<pulumi.CustomResource[]>
Property: "ready",
}, "")
applied = append(applied, ao)
dependsOn = append(dependsOn, "..."+ao.Name)

case "kubernetes:manifest", "kubernetes:kustomize_directory":
ao := tc.NewAppliedOutput(construct.PropertyRef{
Resource: dep,
Expand Down
6 changes: 6 additions & 0 deletions pkg/infra/iac3/templates/aws/target_group/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ function create(args: Args): aws.lb.TargetGroup {
return tg
})()
}

function properties(object: aws.lb.TargetGroup, args: Args) {
return {
Arn: object.arn,
}
}
8 changes: 4 additions & 4 deletions pkg/infra/iac3/templates/kubernetes/helm_chart/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ interface Args {
}

// noinspection JSUnusedLocalSymbols
function create(args: Args): pulumi_k8s.helm.v3.Chart {
return new pulumi_k8s.helm.v3.Chart(
function create(args: Args): pulumi_k8s.helm.v3.Release {
return new pulumi_k8s.helm.v3.Release(
args.Name,
{
//TMPL {{- if .Chart }}
chart: args.Chart,
//TMPL {{- end }}
//TMPL {{- if .Repo }}
fetchOpts: {
repositoryOpts: {
repo: args.Repo,
},
//TMPL {{- end }}
//TMPL {{- if and (not .Chart) .Directory }}
path: args.Directory,
chart: args.Directory,
//TMPL {{- end }}
//TMPL {{- if .Namespace }}
namespace: args.Namespace,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[
{{- range $key, $value := . }}
{
name: {{ modelCase $value.Name }},
name: {{ modelCase $value.name }},
cluster: {
{{- range $key, $value := $value.Cluster }}
{{- if eq $key "Server" }}
{{- range $key, $value := $value.cluster }}
{{- if eq $key "server" }}
"server": {{ modelCase $value }},
{{- else if eq $key "CertificateAuthorityData" }}
{{- else if eq $key "certificateAuthorityData" }}
"certificate-authority-data": {{ modelCase $value }},
{{- end }}
{{- end }}
Expand Down
26 changes: 13 additions & 13 deletions pkg/infra/iac3/templates/kubernetes/kube_config/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import * as pulumi from '@pulumi/pulumi'
import { TemplateWrapper } from '../../wrappers'

interface Args {
ApiVersion: string
Kind: string
Name: string
Clusters: TemplateWrapper<any[]>
Contexts: any[]
Users: any[]
CurrentContext: string
apiVersion: string
kind: string
name: string
clusters: TemplateWrapper<any[]>
contexts: any[]
users: any[]
currentContext: string
}

// noinspection JSUnusedLocalSymbols
function create(args: Args): pulumi.Output<string> {
return pulumi.jsonStringify({
apiVersion: args.ApiVersion,
clusters: args.Clusters,
contexts: args.Contexts,
'current-context': args.CurrentContext,
kind: args.Kind,
users: args.Users,
apiVersion: args.apiVersion,
clusters: args.clusters,
contexts: args.contexts,
'current-context': args.currentContext,
kind: args.kind,
users: args.users,
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ operational_rules:
configuration:
field: TargetType
value: ip
- resource: '{{ .Target }}'
configuration:
field: Object.spec.targetGroupARN
value: '{{ .Source }}#Arn'
- if: |
{{- if not (hasDownstream "kubernetes:service" .Target) }}
false
Expand Down
4 changes: 4 additions & 0 deletions pkg/templates/aws/resources/target_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ properties:
Port:
type: int
default_value: 80
Arn:
type: string
configuration_disabled: true
deploy_time: true

classification:
is:
Expand Down
10 changes: 10 additions & 0 deletions pkg/templates/kubernetes/edges/target_group_binding-service.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
source: kubernetes:target_group_binding
target: kubernetes:service
operational_rules:
- configuration_rules:
- resource: '{{ .Source }}'
configuration:
field: Object.spec.serviceRef.name
value: '{{ fieldValue "Object.metadata.name" .Target }}'
- resource: '{{ .Source }}'
configuration:
field: Object.spec.serviceRef.port
value: '{{ fieldValue "Object.spec.ports[0].port" .Target }}'
4 changes: 2 additions & 2 deletions pkg/templates/kubernetes/resources/target_group_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ properties:
kubernetes:TypeMeta:
type: model
default_value:
apiVersion: v1
kind: ObjectMeta
apiVersion: elbv2.k8s.aws/v1beta1
kind: TargetGroupBinding
metadata:
type: model(kubernetes:ObjectMeta)
spec:
Expand Down

0 comments on commit b3c0f48

Please sign in to comment.