...
 
Commits (2)
......@@ -51,7 +51,29 @@ const (
// instanceID =
)
const (
dataMountPath = "/var/www/html/data"
dataSubPath = "data"
appsMountPath = "/var/www/html/custom_apps"
appsSubPath = "custom_apps"
// NextcloudRuntimeImage is the base image used to run your code
NextcloudRuntimeImage = "indiehosters/nextcloud:16.0.5-2"
// NextcloudWebImage is the base image used to run the application frontend
NextcloudWebImage = "indiehosters/nextcloud-web:16.0.5-1"
// IngressClass is the default ingress class used used for creating WordPress ingresses
IngressClass = ""
)
func (app *Nextcloud) SetDefaults() {
if len(app.Spec.Image) == 0 {
app.Spec.Image = NextcloudRuntimeImage
}
if len(app.Spec.Web.Image) == 0 {
app.Spec.Web.Image = NextcloudWebImage
}
if len(app.Spec.Config.Apps.Store) == 0 {
app.Spec.Config.Apps.Store = appStoreEnabled
}
......
apiVersion: apps.libre.sh/v1alpha1
kind: Nextcloud
namespace: default
metadata:
name: cloud-test-mf
spec:
image: indiehosters/nextcloud:16.0.5-2
replicas: 1
tlsSecretRef: cloud-test-mf-tls
proxy:
image: indiehosters/nextcloud-web:16.0.5-1
storage:
objectStore:
binding:
ref:
namespace: default
name: s3binding
bucket: cloud-test-mf
prefix: data
region: default
config:
overwriteCLI: https://cloud.test.indie.host
overwriteProtocol: https
updateChecker: "false"
version: 16.0.5.1
database:
ref:
namespace: default
name: cloud-test-mf-postgresql
hosts:
- cloud.test.indie.host
ingressAnnotations:
certmanager.k8s.io/cluster-issuer: "letsencrypt-prod"
kubernetes.io/tls-acme: "true"
......@@ -54,7 +54,7 @@ func (r *NextcloudReconciler) SyncDeployment(app Nextcloud) (reconcile.Result, e
GenSecurityContextFunc: GenPodSecurityContext,
},
})
fmt.Println(app.Spec.IngressAnnotations)
if err != nil {
r.Log.Error(err, "Deployment reconcile failed")
return result, err
......
......@@ -35,25 +35,42 @@ func (r *NextcloudReconciler) SyncIngress(app Nextcloud) (reconcile.Result, erro
app.Nextcloud.Spec.Component = "web"
result, err := ingress.CreateOrUpdate(ingress.Conf{
Instance: app.Nextcloud,
Name: fmt.Sprintf("%s-web", app.Nextcloud.Name),
Namespace: app.Nextcloud.Namespace,
GenLabelsFunc: GenLabels,
Reconcile: r,
OwnerReference: true,
GenTLSFunc: GenTLS,
GenRulesFunc: GenRules,
Instance: app.Nextcloud,
Name: fmt.Sprintf("%s-web", app.Nextcloud.Name),
Namespace: app.Nextcloud.Namespace,
GenLabelsFunc: GenLabels,
GenAnnotationsFunc: GenIngressAnnotations,
Reconcile: r,
OwnerReference: true,
GenTLSFunc: GenTLS,
GenRulesFunc: GenRules,
})
if err != nil {
r.Log.Error(err, "Ingress web reconcile failed")
return result, err
}
fmt.Println(app.Spec.IngressAnnotations)
return result, nil
}
func GenIngressAnnotations(obj interfaces.Object) (map[string]string, error) {
var annotations map[string]string
app, ok := obj.(*appsv1alpha1.Nextcloud)
if !ok {
return annotations, errors.New("failed to assert the original object")
}
fmt.Println(app.Spec.IngressAnnotations)
if app.Spec.IngressAnnotations != nil {
return app.Spec.IngressAnnotations, nil
}
return annotations, nil
}
func GenTLS(obj interfaces.Object) ([]networkingv1beta1.IngressTLS, error) {
var ingressTLS []networkingv1beta1.IngressTLS
app, ok := obj.(*appsv1alpha1.Nextcloud)
......
......@@ -106,8 +106,7 @@ func (r *NextcloudReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
} else {
phase = appsv1alpha1.PhaseInstalling
}
// phase := GetAppPhase(app.Nextcloud.Status.Version, app.Nextcloud.Spec.Version)
// phase := appsv1alpha1.PhaseCreating
r.SetAppBindings(*app)
switch {
......
......@@ -29,11 +29,16 @@ var (
wwwDataUserID int64 = 33
)
const (
InternalHTTPPort = 80
InternalFastCGIPort = 9000
)
func GenContainerAppPorts(obj interfaces.Object) ([]corev1.ContainerPort, error) {
ports := make([]corev1.ContainerPort, 1)
ports[0].Name = "http"
ports[0].ContainerPort = int32(9000)
ports[0].ContainerPort = int32(InternalFastCGIPort)
ports[0].Protocol = "TCP"
// ports[0].HostIP = int32(9000)
// ports[0].HostPort = int32(9000)
......@@ -45,7 +50,7 @@ func GenContainerWebPorts(obj interfaces.Object) ([]corev1.ContainerPort, error)
ports := make([]corev1.ContainerPort, 1)
ports[0].Name = "http"
ports[0].ContainerPort = int32(80)
ports[0].ContainerPort = int32(InternalHTTPPort)
ports[0].Protocol = "TCP"
// ports[0].HostIP = int32(9000)
// ports[0].HostPort = int32(9000)
......
......@@ -85,7 +85,7 @@ func PortsForApp(obj interfaces.Object) ([]corev1.ServicePort, error) {
ports := make([]corev1.ServicePort, 1)
ports[0].Name = "http"
ports[0].Port = int32(9000)
ports[0].Port = int32(InternalFastCGIPort)
return ports, nil
}
......@@ -94,7 +94,7 @@ func PortsForWeb(obj interfaces.Object) ([]corev1.ServicePort, error) {
ports := make([]corev1.ServicePort, 1)
ports[0].Name = "http"
ports[0].Port = int32(80)
ports[0].Port = int32(InternalHTTPPort)
return ports, nil
}