Skip to content

Commit

Permalink
adding persistent storage
Browse files Browse the repository at this point in the history
  • Loading branch information
meshuga committed Sep 12, 2024
1 parent 03b8b34 commit b4e7fa5
Show file tree
Hide file tree
Showing 14 changed files with 425 additions and 290 deletions.
7 changes: 7 additions & 0 deletions artifacts/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ spec:
apiserver: "true"
spec:
serviceAccountName: apiserver
volumes:
- name: hykube-provider-storage
persistentVolumeClaim:
claimName: hykube-provider-pvc
containers:
- name: hykube-server
image: hykube-apiserver:latest
imagePullPolicy: Never
volumeMounts:
- mountPath: "/data"
name: hykube-provider-storage
13 changes: 13 additions & 0 deletions artifacts/deployment/pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: hykube-provider-pv
spec:
capacity:
storage: 5Gi # ensure there's enough space for e.g. terraform providers with many versions
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: "/mnt/hykube-provider-data"

10 changes: 10 additions & 0 deletions artifacts/deployment/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hykube-provider-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
File renamed without changes.
8 changes: 5 additions & 3 deletions docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ kubectl create -f artifacts/deployment/auth-reader.yaml -n kube-system
kubectl create -f artifacts/deployment/rbac.yaml
kubectl create -f artifacts/deployment/rbac-bind.yaml

# create the service and replication controller
# create the, PV, PVC, service and replication controller
kubectl create -f artifacts/deployment/pv.yaml -n hykube
kubectl create -f artifacts/deployment/pvc.yaml -n hykube
kubectl create -f artifacts/deployment/deployment.yaml -n hykube
kubectl create -f artifacts/deployment/service.yaml -n hykube

Expand All @@ -77,8 +79,8 @@ kubectl create -f artifacts/deployment/apiservice.yaml
You should now be able to create the resource type `Provider` which is the resource type registered by the API server.

```shell
kubectl create -f artifacts/providers/aws-provider.yaml
# outputs provider "aws-provider" created
kubectl create -f artifacts/providers/aws.yaml
# outputs provider "aws" created
```

You can then get this resource by running:
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/hykube/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ type ProviderSpec struct {
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// TODO add more fields than just spec and stats
type Provider struct {
metav1.TypeMeta
metav1.ObjectMeta

Spec ProviderSpec
Status string
Spec ProviderSpec
Status string
Filename string
}
20 changes: 10 additions & 10 deletions pkg/apis/hykube/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ package v1alpha1
import (
"hykube.io/apiserver/pkg/apis/hykube"
"k8s.io/apimachinery/pkg/conversion"
"unsafe"
)

// Convert_v1alpha1_ProviderSpec_To_hykube_ProviderSpec is an autogenerated conversion function.
func Convert_v1alpha1_ProviderSpec_To_hykube_ProviderSpec(in *ProviderSpec, out *hykube.ProviderSpec, s conversion.Scope) error {
err := autoConvert_v1alpha1_ProviderSpec_To_hykube_ProviderSpec(in, out, s)
if err != nil {
return err
}

if in.ReferenceType != nil {
// assume that ReferenceType is defaulted
switch *in.ReferenceType {
Expand All @@ -26,26 +30,22 @@ func Convert_v1alpha1_ProviderSpec_To_hykube_ProviderSpec(in *ProviderSpec, out
out.ProviderReference = in.Reference
}
}

out.DownloadName = in.DownloadName
out.Version = (*string)(unsafe.Pointer(in.Version))
out.DownloadUrl = (*string)(unsafe.Pointer(in.DownloadUrl))

return nil
}

// Convert_hykube_ProviderSpec_To_v1alpha1_ProviderSpec is an autogenerated conversion function.
func Convert_hykube_ProviderSpec_To_v1alpha1_ProviderSpec(in *hykube.ProviderSpec, out *ProviderSpec, s conversion.Scope) error {
err := autoConvert_hykube_ProviderSpec_To_v1alpha1_ProviderSpec(in, out, s)
if err != nil {
return err
}

switch in.ReferenceType {
case hykube.ProviderReferenceType:
t := ProviderReferenceType
out.ReferenceType = &t
out.Reference = in.ProviderReference
}

out.DownloadName = in.DownloadName
out.Version = (*string)(unsafe.Pointer(in.Version))
out.DownloadUrl = (*string)(unsafe.Pointer(in.DownloadUrl))

return nil
}
5 changes: 3 additions & 2 deletions pkg/apis/hykube/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Provider struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

Spec ProviderSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
Status string `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
Spec ProviderSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
Status string `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
Filename string `json:"filename,omitempty" protobuf:"bytes,4,opt,name=filename"`
}
2 changes: 2 additions & 0 deletions pkg/apis/hykube/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/generated/applyconfiguration/hykube/v1alpha1/provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/registry/hykube/provider/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (*reg
return nil, err
}
providerWatcher := watcher{
watch: watch,
store: store,
watch: watch,
hashicorpProvider: NewHashicorpProvider(store),
}
providerWatcher.Start()

Expand Down
Loading

0 comments on commit b4e7fa5

Please sign in to comment.