Skip to content

Commit 49200cc

Browse files
Refactor existing APIs to use APIResourceSchema, BoundAPIResourceSchema for service exposure (#261)
* Refactor APIServiceExport and APIServiceExportRequest for v1alpha2 Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * storage version Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * add APIServiceBinding v1alpha2 Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * update konnector to v1alpha2 Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * update cmd and example-backend to v1alpha2 Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * update go.mod Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * refactor konnector serviceexport and servicebinding controllers Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * update service binding reconciler Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * refactor example backend Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * refactor example backend Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix lint Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * remove validation rules Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * add crds to e2e Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * add rbac e2e Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * setup with local kind Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * fix backend kind cluster Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * make apiresourceschemas cluster scoped Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * add version gate * nit * Move towards single kind cluster * Add additional perms to read schemas * Fix conditions * fix race condition * fix test * update readme * add short names to crds and prealloc hashes Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com * update readme, move kcp setup to quickstart page Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com --------- Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent 19b1211 commit 49200cc

226 files changed

Lines changed: 15592 additions & 1228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ linters:
6868
- linters:
6969
- goconst
7070
path: (.+)_test\.go
71+
- linters:
72+
- staticcheck
73+
text: QF1008
7174
paths:
7275
- pkg/client
7376
- third_party$

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SHELL := /usr/bin/env bash -e
1717

1818
GO_INSTALL = ./hack/go-install.sh
1919

20+
ROOT_DIR=$(abspath .)
2021
TOOLS_DIR=hack/tools
2122
TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR))
2223
GOBIN_DIR=$(abspath ./bin )
@@ -151,9 +152,13 @@ $(CODE_GENERATOR):
151152
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/code-generator/v2 $(CODE_GENERATOR_BIN) $(CODE_GENERATOR_VER)
152153

153154
lint: $(GOLANGCI_LINT) $(LOGCHECK) ## Run linters
154-
$(GOLANGCI_LINT) run ./...
155+
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_FLAGS) -c $(ROOT_DIR)/.golangci.yaml --timeout 20m
155156
.PHONY: lint
156157

158+
fix-lint: $(GOLANGCI_LINT)
159+
GOLANGCI_LINT_FLAGS="--fix" $(MAKE) lint
160+
.PHONY: fix-lint
161+
157162
vendor: ## Vendor the dependencies
158163
go mod tidy
159164
go mod vendor
@@ -250,6 +255,9 @@ $(KCP):
250255
tar xz -C "$(TOOLS_DIR)" --strip-components="1" bin/kcp
251256
mv $(TOOLS_DIR)/kcp $(KCP)
252257

258+
run-kcp: $(KCP)
259+
$(KCP) start
260+
253261
.PHONY: test-e2e
254262
ifdef USE_GOTESTSUM
255263
test-e2e: $(GOTESTSUM)
@@ -354,7 +362,7 @@ image-local:
354362
@echo "Successfully built local images with tag $(REV)"
355363

356364
.PHONY: kind-load
357-
kind-load: image-local ## Load locally built images into kind cluster
365+
kind-load:
358366
@echo "Loading images into kind cluster '$(KIND_CLUSTER)'"
359367
kind load docker-image $(KO_DOCKER_REPO)/konnector:$(REV) --name $(KIND_CLUSTER)
360368
kind load docker-image $(KO_DOCKER_REPO)/example-backend:$(REV) --name $(KIND_CLUSTER)

README.md

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# kube-bind
44

5-
### Disclaimer: work in progress and not ready for production use.
5+
### Disclaimer: work in progress and not ready for production use.
66

77
You are invited to [contribute](#contributing)!
88

@@ -26,9 +26,9 @@ $ kubectl krew index add bind https://github.com/kube-bind/krew-index.git
2626
$ kubectl krew install bind/bind
2727
$ kubectl bind https://mangodb/exports
2828
Redirect to the brower to authenticate via OIDC.
29-
BOOM – the MangoDB API is available in the local cluster,
29+
BOOM – the MangoDB API is available in the local cluster,
3030
without anything MangoDB-specific running.
31-
$ kubectl get mangodbs
31+
$ kubectl get mangodbs
3232
```
3333

3434
## For more information
@@ -42,7 +42,7 @@ The kube-bind prototype is following this manifesto from the linked talk:
4242

4343
## Contributing
4444

45-
We ❤️ our contributors! If you're interested in helping us out, please check out
45+
We ❤️ our contributors! If you're interested in helping us out, please check out
4646
[Contributing to kube-bind](./CONTRIBUTING.md) and [kube-bind Project Governance](./GOVERNANCE.md).
4747

4848
## Getting in touch
@@ -60,54 +60,25 @@ All the actions shown between the clusters are done by the konnector, except: th
6060

6161
## Usage
6262

63-
To run the current backend, there must be an OIDC issuer installed in place to do the
64-
the oauth2 workflow.
65-
66-
We use dex to manage OIDC, following the steps below you can run a local OIDC issuer using dex:
67-
* First, clone the dex repo: `git clone https://github.com/dexidp/dex.git`
68-
* `cd dex` and then build the dex binary `make build`
69-
* The binary will be created in `bin/dex`
70-
* Adjust the config file(`examples/config-dev.yaml`) for dex by specifying the server callback method:
71-
```yaml
72-
staticClients:
73-
- id: kube-bind
74-
redirectURIs:
75-
- 'http://127.0.0.1:8080/callback'
76-
name: 'Kube Bind'
77-
```
78-
* Run dex: `./bin/dex serve examples/config-dev.yaml`
63+
To get familiar with setting up the environment, please check out docs at [kube-bind.io](https://docs.kube-bind.io/main/setup).
7964

80-
Next you should be able to run the backend. For it you need a kubernetes cluster (e.g. kind)
81-
accessible.
65+
## API Changes in coming v0.5.0 release
8266

83-
***Note: make sure before running the backend that you have the dex server up and running as mentioned above
84-
and that you have at least one k8s cluster. Take a look at the backend option in the cmd/main.go file***
67+
Version v0.5.0 includes significant architectural improvements to the API structure:
8568

86-
* apply the CRDs: `kubectl apply -f deploy/crd`
87-
* In order to populate binding list on website, we need a CRD with label `kube-bind.io/exported: true`. Apply example CRD: `kubectl apply -f deploy/examples/crd-mangodb.yaml`
88-
* start the backend binary with the right flags:
89-
```shell
90-
$ make build
91-
$ bin/example-backend \
92-
--oidc-issuer-client-secret=ZXhhbXBsZS1hcHAtc2VjcmV0 \
93-
--oidc-issuer-client-id=kube-bind \
94-
--oidc-issuer-url=http://127.0.0.1:5556/dex \
95-
--oidc-callback-url=http://127.0.0.1:8080/callback \
96-
--pretty-name="BigCorp.com" \
97-
--namespace-prefix="kube-bind-" \
98-
--cookie-signing-key=bGMHz7SR9XcI9JdDB68VmjQErrjbrAR9JdVqjAOKHzE= \
99-
--cookie-encryption-key=wadqi4u+w0bqnSrVFtM38Pz2ykYVIeeadhzT34XlC1Y=
100-
```
69+
### Major Changes
10170

102-
where `ZXhhbXBsZS1hcHAtc2VjcmV0` matches the value of the dex config file.
71+
- **API Version Upgrade**: Introduced `v1alpha2` API version with improved stability and features
72+
- **Service Exposure Refactoring**: Completely refactored the service exposure mechanism to use:
73+
- `APIResourceSchema`: Define the schema of exported CRDs, allowing one APIServiceExport to reference multiple CRDs.
74+
- `BoundAPIResourceSchema`: Represent bound schemas in consumer clusters and underlying status of synced resources.
10375

104-
The `--cookie-signing-key` and `--cookie-encryption-key` settings can be generated using:
105-
```shell
106-
$ openssl rand -base64 32
107-
WQh88mNOY0Z3tLy1/WOud7qIEEBxz+POc4j8BsYenYo=
108-
```
76+
### Limitations
10977

110-
The `--cookie-signing-key` option is required and supports 32 and 64 byte lengths.
111-
The `--cookie-encryption-key` option is optional and supports byte lengths of 16, 24, 32 for AES-128, AES-192, or AES-256.
78+
These limitations are part of the roadmap and will be addressed in the future.
11279

113-
* with a KUBECONFIG against another cluster (a consumer cluster) bind a service: `kubectl bind http://127.0.0.1:8080/export`.
80+
* Currently we don't support related resources, like ConfigMaps, Secrets
81+
* Currently CRD resources MUST be installed in the provider cluster, even when APIResourceSchema is used.
82+
This is to allow the konnector to sync instances of the CRD to the consumer cluster.
83+
This should be removed once we introduce sync policies and object wrappers.
84+
* Currently we dont support granular permissions, like only allow to read/write certain named resources.

cli/go.mod

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ module github.com/kube-bind/kube-bind/cli
22

33
go 1.23.4
44

5-
replace github.com/kube-bind/kube-bind/sdk/apis => ../sdk/apis
5+
replace (
6+
github.com/kube-bind/kube-bind => ../
7+
github.com/kube-bind/kube-bind/sdk/apis => ../sdk/apis
8+
github.com/kube-bind/kube-bind/sdk/client => ../sdk/client
9+
)
610

711
require (
812
github.com/MakeNowJust/heredoc v1.0.0
913
github.com/blang/semver/v4 v4.0.0
1014
github.com/fatih/color v1.18.0
11-
github.com/kube-bind/kube-bind v0.4.6
12-
github.com/kube-bind/kube-bind/sdk/apis v0.4.6
13-
github.com/kube-bind/kube-bind/sdk/client v0.4.6
15+
github.com/kube-bind/kube-bind v0.0.0-00010101000000-000000000000
16+
github.com/kube-bind/kube-bind/sdk/apis v0.4.8
17+
github.com/kube-bind/kube-bind/sdk/client v0.0.0-20250515145715-d9f20e7c840d
1418
github.com/mdp/qrterminal/v3 v3.2.0
1519
github.com/muesli/reflow v0.3.0
1620
github.com/spf13/cobra v1.8.1

cli/go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
115115
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
116116
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
117117
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
118-
github.com/kube-bind/kube-bind v0.4.6 h1:XOa1Ac3tn5aJARni/f9+rNcvr4XEzRGXlzWhn0kkbVo=
119-
github.com/kube-bind/kube-bind v0.4.6/go.mod h1:+xqzeod5hyVPEe0GaZXAnhaipmH5pusNfPmyVALkvcA=
120-
github.com/kube-bind/kube-bind/sdk/client v0.4.6 h1:zcBA3qWAnRmbRaZZX62JPdLUA30n0CrE+fxzEowH0Ok=
121-
github.com/kube-bind/kube-bind/sdk/client v0.4.6/go.mod h1:BaLx9LytSHd6s+VRNiNdleqnNzHoV1A5AoUvskyJ9tc=
122118
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
123119
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
124120
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=

cli/pkg/crd2apiresourceschema/plugin/crd2apiresourceschema.go

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package plugin
1818

1919
import (
2020
"context"
21-
"encoding/json"
2221
"errors"
2322
"fmt"
2423
"io"
@@ -41,6 +40,7 @@ import (
4140

4241
"github.com/kube-bind/kube-bind/cli/pkg/kubectl/base"
4342
kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
43+
"github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers"
4444
)
4545

4646
type CRD2APIResourceSchemaOptions struct {
@@ -116,7 +116,7 @@ func (b *CRD2APIResourceSchemaOptions) Run(ctx context.Context) error {
116116
}
117117

118118
prefix := fmt.Sprintf("v%s-%s", time.Now().Format("060102"), string(version.Get().GitCommit))
119-
apiResourceSchema, err := convertCRDToAPIResourceSchema(crdObj, prefix)
119+
apiResourceSchema, err := helpers.CRDToAPIResourceSchema(crdObj, prefix)
120120
if err != nil {
121121
fmt.Fprintf(b.Options.ErrOut, "Failed to convert CRD %s to APIResourceSchema: %v\n", crdObj.Name, err)
122122
continue
@@ -158,82 +158,6 @@ func generateAPIResourceSchemaInCluster(ctx context.Context, client dynamic.Inte
158158
return nil
159159
}
160160

161-
func convertCRDToAPIResourceSchema(crd *apiextensionsv1.CustomResourceDefinition, prefix string) (*kubebindv1alpha2.APIResourceSchema, error) {
162-
name := prefix + "." + crd.Name
163-
informerScope := kubebindv1alpha2.NamespacedScope
164-
apiResourceSchema := &kubebindv1alpha2.APIResourceSchema{
165-
TypeMeta: metav1.TypeMeta{
166-
APIVersion: kubebindv1alpha2.SchemeGroupVersion.String(),
167-
Kind: "APIResourceSchema",
168-
},
169-
ObjectMeta: metav1.ObjectMeta{
170-
Name: name,
171-
},
172-
Spec: kubebindv1alpha2.APIResourceSchemaSpec{
173-
InformerScope: informerScope,
174-
APIResourceSchemaCRDSpec: kubebindv1alpha2.APIResourceSchemaCRDSpec{
175-
Group: crd.Spec.Group,
176-
Names: crd.Spec.Names,
177-
Scope: crd.Spec.Scope,
178-
},
179-
},
180-
}
181-
182-
if len(crd.Spec.Versions) > 1 && crd.Spec.Conversion == nil {
183-
return nil, fmt.Errorf("multiple versions specified for CRD %q but no conversion strategy", crd.Name)
184-
}
185-
186-
if crd.Spec.Conversion != nil {
187-
crConversion := &kubebindv1alpha2.CustomResourceConversion{
188-
Strategy: kubebindv1alpha2.ConversionStrategyType(crd.Spec.Conversion.Strategy),
189-
}
190-
191-
if crd.Spec.Conversion.Strategy == "Webhook" {
192-
crConversion.Webhook = &kubebindv1alpha2.WebhookConversion{
193-
ConversionReviewVersions: crd.Spec.Conversion.Webhook.ConversionReviewVersions,
194-
}
195-
196-
if crd.Spec.Conversion.Webhook.ClientConfig != nil {
197-
crConversion.Webhook.ClientConfig = &kubebindv1alpha2.WebhookClientConfig{
198-
URL: crd.Spec.Conversion.Webhook.ClientConfig.URL,
199-
CABundle: crd.Spec.Conversion.Webhook.ClientConfig.CABundle,
200-
}
201-
}
202-
}
203-
204-
apiResourceSchema.Spec.Conversion = crConversion
205-
}
206-
207-
for i := range crd.Spec.Versions {
208-
crdVersion := crd.Spec.Versions[i]
209-
210-
apiResourceVersion := kubebindv1alpha2.APIResourceVersion{
211-
Name: crdVersion.Name,
212-
Served: crdVersion.Served,
213-
Storage: crdVersion.Storage,
214-
Deprecated: crdVersion.Deprecated,
215-
DeprecationWarning: crdVersion.DeprecationWarning,
216-
AdditionalPrinterColumns: crdVersion.AdditionalPrinterColumns,
217-
}
218-
219-
if crdVersion.Schema != nil && crdVersion.Schema.OpenAPIV3Schema != nil {
220-
rawSchema, err := json.Marshal(crdVersion.Schema.OpenAPIV3Schema)
221-
if err != nil {
222-
return nil, fmt.Errorf("error converting schema for version %q: %w", crdVersion.Name, err)
223-
}
224-
apiResourceVersion.Schema = runtime.RawExtension{Raw: rawSchema}
225-
}
226-
227-
if crdVersion.Subresources != nil {
228-
apiResourceVersion.Subresources = *crdVersion.Subresources
229-
}
230-
231-
apiResourceSchema.Spec.Versions = append(apiResourceSchema.Spec.Versions, apiResourceVersion)
232-
}
233-
234-
return apiResourceSchema, nil
235-
}
236-
237161
func writeObjectToYAML(outputDir string, apiResourceSchema *kubebindv1alpha2.APIResourceSchema, logger io.Writer) error {
238162
if err := os.MkdirAll(outputDir, 0755); err != nil {
239163
return fmt.Errorf("failed to create output directory %s: %w", outputDir, err)

cli/pkg/kubectl/bind-apiservice/plugin/bind.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040
"sigs.k8s.io/yaml"
4141

4242
"github.com/kube-bind/kube-bind/cli/pkg/kubectl/base"
43-
kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1"
43+
kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
4444
)
4545

4646
// BindAPIServiceOptions are the options for the kubectl-bind-apiservice command.
@@ -257,12 +257,12 @@ func (b *BindAPIServiceOptions) getRequestManifest() ([]byte, error) {
257257
return body, nil
258258
}
259259

260-
func (b *BindAPIServiceOptions) unmarshalManifest(bs []byte) (*kubebindv1alpha1.APIServiceExportRequest, error) {
261-
var request kubebindv1alpha1.APIServiceExportRequest
260+
func (b *BindAPIServiceOptions) unmarshalManifest(bs []byte) (*kubebindv1alpha2.APIServiceExportRequest, error) {
261+
var request kubebindv1alpha2.APIServiceExportRequest
262262
if err := yaml.Unmarshal(bs, &request); err != nil {
263263
return nil, fmt.Errorf("failed to unmarshal manifest: %w", err)
264264
}
265-
if request.APIVersion != kubebindv1alpha1.SchemeGroupVersion.String() {
265+
if request.APIVersion != kubebindv1alpha2.SchemeGroupVersion.String() {
266266
return nil, fmt.Errorf("invalid apiVersion %q", request.APIVersion)
267267
}
268268
if request.Kind != "APIServiceExportRequest" {

cli/pkg/kubectl/bind-apiservice/plugin/konnector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (b *BindAPIServiceOptions) deployKonnector(ctx context.Context, config *res
111111
}
112112
first := true
113113
return wait.PollUntilContextCancel(ctx, 1*time.Second, true, func(ctx context.Context) (bool, error) {
114-
_, err := bindClient.KubeBindV1alpha1().APIServiceBindings().List(ctx, metav1.ListOptions{})
114+
_, err := bindClient.KubeBindV1alpha2().APIServiceBindings().List(ctx, metav1.ListOptions{})
115115
if err == nil {
116116
if !first {
117117
fmt.Fprintln(b.Options.IOStreams.ErrOut) //nolint:errcheck

cli/pkg/kubectl/bind-apiservice/plugin/servicebindings.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import (
2727
"k8s.io/apimachinery/pkg/util/wait"
2828
"k8s.io/client-go/rest"
2929

30-
kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1"
31-
"github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1/helpers"
30+
kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
31+
"github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers"
3232
conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1"
3333
"github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/util/conditions"
3434
bindclient "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned"
3535
)
3636

37-
func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, config *rest.Config, request *kubebindv1alpha1.APIServiceExportRequest, secretName string) ([]*kubebindv1alpha1.APIServiceBinding, error) {
37+
func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, config *rest.Config, request *kubebindv1alpha2.APIServiceExportRequest, secretName string) ([]*kubebindv1alpha2.APIServiceBinding, error) {
3838
bindClient, err := bindclient.NewForConfig(config)
3939
if err != nil {
4040
return nil, err
@@ -44,10 +44,10 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co
4444
return nil, err
4545
}
4646

47-
var bindings []*kubebindv1alpha1.APIServiceBinding
47+
var bindings []*kubebindv1alpha2.APIServiceBinding
4848
for _, resource := range request.Spec.Resources {
4949
name := resource.Resource + "." + resource.Group
50-
existing, err := bindClient.KubeBindV1alpha1().APIServiceBindings().Get(ctx, name, metav1.GetOptions{})
50+
existing, err := bindClient.KubeBindV1alpha2().APIServiceBindings().Get(ctx, name, metav1.GetOptions{})
5151
if err != nil && !apierrors.IsNotFound(err) {
5252
return nil, err
5353
} else if err == nil {
@@ -76,14 +76,14 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co
7676
first = false
7777
fmt.Fprint(b.Options.IOStreams.ErrOut, ".") //nolint:errcheck
7878
}
79-
created, err := bindClient.KubeBindV1alpha1().APIServiceBindings().Create(ctx, &kubebindv1alpha1.APIServiceBinding{
79+
created, err := bindClient.KubeBindV1alpha2().APIServiceBindings().Create(ctx, &kubebindv1alpha2.APIServiceBinding{
8080
ObjectMeta: metav1.ObjectMeta{
8181
Name: resource.Resource + "." + resource.Group,
8282
Namespace: "kube-bind",
8383
},
84-
Spec: kubebindv1alpha1.APIServiceBindingSpec{
85-
KubeconfigSecretRef: kubebindv1alpha1.ClusterSecretKeyRef{
86-
LocalSecretKeyRef: kubebindv1alpha1.LocalSecretKeyRef{
84+
Spec: kubebindv1alpha2.APIServiceBindingSpec{
85+
KubeconfigSecretRef: kubebindv1alpha2.ClusterSecretKeyRef{
86+
LocalSecretKeyRef: kubebindv1alpha2.LocalSecretKeyRef{
8787
Name: secretName,
8888
Key: "kubeconfig",
8989
},
@@ -102,7 +102,7 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co
102102
conditionsapi.ConditionSeverityInfo,
103103
"Pending",
104104
)
105-
_, _ = bindClient.KubeBindV1alpha1().APIServiceBindings().UpdateStatus(ctx, created, metav1.UpdateOptions{}) //nolint:errcheck
105+
_, _ = bindClient.KubeBindV1alpha2().APIServiceBindings().UpdateStatus(ctx, created, metav1.UpdateOptions{}) //nolint:errcheck
106106

107107
fmt.Fprintf(b.Options.IOStreams.ErrOut, "✅ Created APIServiceBinding %s.%s\n", resource.Resource, resource.Group) //nolint:errcheck
108108
bindings = append(bindings, created)

0 commit comments

Comments
 (0)