Hi, I am newbie, how i can tweak this code to pass...
# kubernetes
e
Hi, I am newbie, how i can tweak this code to pass Port and TargetPort with different values ? https://github.com/pulumi/examples/blob/master/kubernetes-go-guestbook/components/serviceDeployment.go#L106
b
where would you be sourcing the values from? an output? what have you tried?
e
currently i am passing the values of Port and TargetPort from my YAML Stack Config, the related part is: config: tadkiratiIsMiniKube "true" tadkiratiKeycloak image: "quay.io/keycloak/keycloak:20.0.3" ports: [8282] targetPorts: [8080] replica: 1 ....... Then i fit the above config into the following Struct:
type Keycloak struct {
Username    string
Password    string
Image       string
Ports       []int
TargetPorts []int
Replica     int
Args        []string
Command     []string
Env         map[string]string
}
I also modified the original
ServiceDeploymentArgs
Struct as follows: type ServiceDeploymentArgs struct { AllocateIPAddress pulumi.Bool Image pulumi.StringInput IsMinikube pulumi.Bool Ports pulumi.IntArrayInput TargetPorts pulumi.IntArrayInput Replicas pulumi.IntPtrInput Args pulumi.StringArrayInput Command pulumi.StringArrayInput Env map[string]string } Then i tweaked
NewServiceDeployment
Method as follows:
_, err = NewServiceDeployment(ctx, "keycloak-app", &ServiceDeploymentArgs{
Image:       pulumi.String(Keycloak.Image),
Ports:       pulumi.ToIntArray(Keycloak.Ports),
TargetPorts: pulumi.ToIntArray(Keycloak.TargetPorts),
Args:        toStringArrayInput(Keycloak.Args),
Env:         Keycloak.Env,
})
That is all i did so far
Tried also to use pulumi.All as follows but got the below error message :
servicePorts := pulumi.All(portsOutput, targetPortsOutput).ApplyT(func(ports []interface{}) []corev1.ServicePort {
var result []corev1.ServicePort
for _, port := range ports {
fmt.Println(port)
result = append(result, corev1.ServicePort{
Port:       int(port.(int)),
TargetPort: port,
})
}
return result
}).(corev1.ServicePortArrayOutput)
panic: interface conversion: interface {} is []int, not int goroutine 66 [running]: main.NewServiceDeployment.func2({0xc00006c2c0?, 0x2, 0x1?}) /home/hachi/MyDATA/eadn/Projects/Programming/Go/Pulumi/k8s/tadkirati/ServiceDeployment.go:108 +0x251