-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support k8s service bindings #555
Conversation
- Add v1alpha2 for Builds and Images - Add conversion webhook for crds - Continue to support v1alpha1 bindings in controller - Small breaking change in v1alpha1 api code (lastSource) - Conversion strategy for v1alpha1 -> v1alpha2 is via annotation - Do not remove any v1alpha1 api code #536
ProvisionedService has no notion of "Ready" either there is a Secret that can be read, or there isn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I missed it, but I didn't see where the "application projection" is occurring. The Service Binding for K8s Spec is not the CNB Binding Spec minus a ConfigMap. Check out https://github.com/k8s-service-bindings/spec#application-projection
RBAC can be defined generically, take a look at https://github.com/k8s-service-bindings/spec#for-service-binding-implementors
Co-authored-by: Scott Andrews <sandrews@pivotal.io>
- Secret .stringData.type must be set and reflect .type as service.binding/{type} - Add RBAC aggregationRule for kpack controller to access ProvisionedServices - Default APIVersion to v1 for Secret service bindings - validate services .kind is set #536
Many thanks @scothis for looking at this! Made some changes from the feedback.
I was missing the |
pkg/apis/build/v1alpha2/build_pod.go
Outdated
// If this is a v1alpha1 binding | ||
if s.V1Alpha1MetadataRef != nil { | ||
metadataVolume := fmt.Sprintf("service-binding-metadata-%s", s.Name) | ||
volumes = append(volumes, | ||
corev1.Volume{ | ||
Name: metadataVolume, | ||
VolumeSource: corev1.VolumeSource{ | ||
ConfigMap: &corev1.ConfigMapVolumeSource{ | ||
LocalObjectReference: *s.V1Alpha1MetadataRef, | ||
}, | ||
}, | ||
}, | ||
) | ||
volumeMounts = append(volumeMounts, | ||
corev1.VolumeMount{ | ||
Name: metadataVolume, | ||
MountPath: filepath.Join(platformVolume.MountPath, "bindings", s.Name, "metadata"), | ||
ReadOnly: true, | ||
}, | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no "metadata" directory in the k8s service binding spec, and the secret is in the wrong place for the cnb service binding spec.
rm unless this is doing something meaningful that I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I did this wrong, fixing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be fixed now
|
||
for i, s := range b.Spec.Services { | ||
if s.Kind == "Secret" && s.APIVersion == "" { | ||
b.Spec.Services[i].APIVersion = "v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there precedent for defaulting the APIVersion in an object reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just me speculating that this might help usability
} | ||
serviceBindingRootEnv = corev1.EnvVar{ | ||
Name: serviceBindingRootEnvVar, | ||
Value: filepath.Join(platformVolume.MountPath, "bindings"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K8s service bindings and cnb service bindings should not share the same directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylerphelan that makes sense to me. I always assumed it would be either/or and not both.
- aggregationRule will overwrite existing rules #536
- refactor
@tylerphelan If we are holding off on this for a bit could we move it draft? |
|
||
"github.com/pivotal/kpack/pkg/apis/build/v1alpha1" | ||
"github.com/pivotal/kpack/pkg/apis/build/v1alpha2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really the best approach to mix build/v1alpha1
and build/v1alpha2
? It can get very tricky which struct to take from which import and the errors can be very subtle.
Another approach would bump the api as a whole and only use build/v1alpha2
. Maybe even use a import like
buildapi "github.com/pivotal/kpack/pkg/apis/build/v1alpha2"
So the code didn't have to be changed all over if a version is bumped.
Tagging this as |
closed in favor of #823 |
Issue: #536
Open questions:
ProvisionedService
s?- Is there a race condition betweenProvisionedService
s andBuild
s reconciling? (if aProvisionedService
is notReady
yet will theBuild
fail?)meta.UnsafeGuessKindToResource
, is that alright?v1alpha2
but we could dov1beta1
master
branch does not have inaccurate docs?generator.go
to check that service binding secrets include the requiredtype
anddata.type
based on the spec. Would love thoughts on that. Is it necessary?Notes:
ProvisionedService
withkpack
users will need to create rbac that allows thekpack-controller
toget
the resource via the spec