Hi everyone, i'm a bit lost with the kubernetes-sd...
# kubernetes
Hi everyone, i'm a bit lost with the kubernetes-sdk in Go. I don't see how we can provide for our developers a simple way to use reusable libraries. My idea is to provide for example a library adding a volume and a volume mount to every deployment. Really a simple chain of modification like we would do with the go sdk.
Copy code
deployment, err := MyCustomGen(name)
err = MyCustomDeploymentPatch(deployment)
I might be missing something bu i don't see how it's feasible with the pulumi-sdk. My question basically is how can we do two-pass modification on any object.
hey! The way to do this is to create a Component: https://www.pulumi.com/docs/intro/concepts/programming-model/#components you'd define options and a struct which gets passed as args. you can see an example here: https://github.com/jaxxstorm/pulumi-clusterautoscalerx/blob/master/main.go it's them useable as a standard Go module
Thanks @billowy-army-68599. I've been trying to write up what i want to achieve for the last 40minutes, but i give up and give you a simple question instead. What is the good way in the go-sdk to read and modify args (DeploymentSpecArgs for example) and modify them. Let's say i want to iterate over a range of Volume inside a DeploymentSpecArgs. Yes that's my question 🙂
do you mean for an existing deployment that hasn't been created using Pulumi?
no, i mean:
Copy code
		Metadata: metav1.ObjectMetaArgs{
			Annotations: annotations,
			Namespace:   pulumi.String(namespace),
			Name:        pulumi.String(app.Name),
		Spec: appsv1.DeploymentSpecArgs{
			Selector: &metav1.LabelSelectorArgs{
				MatchLabels: labels,
			Strategy: appsv1.DeploymentStrategyArgs{
				RollingUpdate: appsv1.RollingUpdateDeploymentArgs{
					MaxSurge:       pulumi.String("35%"),
					MaxUnavailable: pulumi.String("0%"),
			Template: &corev1.PodTemplateSpecArgs{
				Metadata: &metav1.ObjectMetaArgs{
					Labels: labels,
				Spec: &corev1.PodSpecArgs{
					Containers: containers,
imagine wanting to range over MatchLabels
that's it
that would mean casting the type of whatever u'd want to access i guess
instead of just iterate over it
how is
(the variable) defined?
takes a
which should be iterable
ok wrong example in that case
imagine the labels being defined in the args
you would have the following error
Copy code
pkg/mutations/deployment.go:117:8: d.Spec.Selector undefined (type "<http://github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/apps/v1|github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/apps/v1>".DeploymentSpecPtrInput has no field or method Selector
because each field is an interface instead of being the actual field
sorry, it's a little difficult understanding without the full example, I'm not following I'm afraid
i'm getting lost too sorry mate
let me build up a full example i'll shoot u that tomorrow (2am here)
👍 1