Skip to content

Commit

Permalink
Merge pull request #63 from cloud-ark/moodle-wiris-update
Browse files Browse the repository at this point in the history
Updated wiris plugin link
  • Loading branch information
devdattakulkarni authored Jun 14, 2019
2 parents e0d9968 + 83e25e2 commit 9b633dc
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 11 deletions.
5 changes: 3 additions & 2 deletions moodle/moodle-operator-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apiVersion: v1
appVersion: "1.0"
sources:
- https://github.com/cloud-ark/kubeplus-operators/releases/tag/v1
- https://github.com/cloud-ark/kubeplus-operators/tree/master/moodle tag: 0.4.8
description: A Helm chart for Moodle Operator
name: moodle-operator-chart
version: 0.4.7
version: 0.4.8

8 changes: 4 additions & 4 deletions moodle/moodle-operator-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ spec:
spec:
containers:
- name: moodle-operator
image: lmecld/moodle-operator:0.4.7
image: lmecld/moodle-operator:0.4.8
imagePullPolicy: Always
command: [ "/moodle"]
env:
- name: HOST_IP
value: {{ .Values.HOST_IP }}
#env:
#- name: HOST_IP
# value: {{ .Values.HOST_IP }}
#env:
#- name: HOST_IP
# valueFrom:
Expand Down
128 changes: 124 additions & 4 deletions moodle/moodle.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ func (c *MoodleController) createIngress(foo *operatorv1.Moodle) {
moodleDomainName := foo.Spec.DomainName
moodleTLSCertSecretName := moodleName + "-domain-cert"

//moodlePath := "/" + moodleName
moodlePath := "/"
if moodleDomainName == "" {
moodlePath = moodlePath + moodleName
}

moodleServiceName := moodleName

moodlePort := MOODLE_PORT

specObj := getIngressSpec(moodlePort, moodleDomainName, moodlePath,
moodleTLSCertSecretName, moodleServiceName)

ingress := &extensionsv1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: moodleName,
Expand All @@ -137,6 +143,8 @@ func (c *MoodleController) createIngress(foo *operatorv1.Moodle) {
},
},
},
Spec: specObj,
/*
Spec: extensionsv1beta1.IngressSpec{
TLS: []extensionsv1beta1.IngressTLS{
{
Expand All @@ -163,6 +171,7 @@ func (c *MoodleController) createIngress(foo *operatorv1.Moodle) {
},
},
},
*/
}

namespace := getNamespace(foo)
Expand All @@ -176,6 +185,63 @@ func (c *MoodleController) createIngress(foo *operatorv1.Moodle) {
fmt.Printf("MoodleController.go : Created Ingress %q.\n", result.GetObjectMeta().GetName())
}

func getIngressSpec(moodlePort int, moodleDomainName, moodlePath, moodleTLSCertSecretName,
moodleServiceName string) extensionsv1beta1.IngressSpec {

var specObj extensionsv1beta1.IngressSpec

if moodleDomainName != "" {
specObj = extensionsv1beta1.IngressSpec{
TLS: []extensionsv1beta1.IngressTLS{
{
Hosts: []string{moodleDomainName},
SecretName: moodleTLSCertSecretName,
},
},
Rules: []extensionsv1beta1.IngressRule{
{
Host: moodleDomainName,
IngressRuleValue: extensionsv1beta1.IngressRuleValue{
HTTP: &extensionsv1beta1.HTTPIngressRuleValue{
Paths: []extensionsv1beta1.HTTPIngressPath{
{
Path: moodlePath,
Backend: extensionsv1beta1.IngressBackend{
ServiceName: moodleServiceName,
ServicePort: apiutil.FromInt(moodlePort),
},
},
},
},
},
},
},
}
} else {
specObj = extensionsv1beta1.IngressSpec{
Rules: []extensionsv1beta1.IngressRule{
{
IngressRuleValue: extensionsv1beta1.IngressRuleValue{
HTTP: &extensionsv1beta1.HTTPIngressRuleValue{
Paths: []extensionsv1beta1.HTTPIngressPath{
{
Path: moodlePath,
Backend: extensionsv1beta1.IngressBackend{
ServiceName: moodleServiceName,
ServicePort: apiutil.FromInt(moodlePort),
},
},
},
},
},
},
},
}
}

return specObj
}

func (c *MoodleController) createPersistentVolume(foo *operatorv1.Moodle) {
fmt.Println("MoodleController.go : Inside createPersistentVolume")

Expand Down Expand Up @@ -493,8 +559,12 @@ func (c *MoodleController) createDeployment(foo *operatorv1.Moodle) (error, stri
}
fmt.Printf("MoodleController.go : Created deployment %q.\n", result.GetObjectMeta().GetName())

/*
podname, _ := c.util.GetPodFullName(constants.TIMEOUT, foo.Name, foo.Namespace)
moodlePodName, podReady := c.util.WaitForPod(constants.TIMEOUT, podname, foo.Namespace)
*/

moodlePodName, podReady := c.waitForPod(foo)

if podReady {
return nil, moodlePodName, secretName
Expand Down Expand Up @@ -580,6 +650,8 @@ func (c *MoodleController) createService(foo *operatorv1.Moodle) string {

namespace := getNamespace(foo)
serviceClient := c.kubeclientset.CoreV1().Services(namespace)

serviceObj := getServiceSpec(moodlePort, deploymentName, foo.Spec.DomainName)
service := &apiv1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: deploymentName,
Expand All @@ -595,6 +667,9 @@ func (c *MoodleController) createService(foo *operatorv1.Moodle) string {
"app": deploymentName,
},
},
Spec: serviceObj,

/*
Spec: apiv1.ServiceSpec{
Ports: []apiv1.ServicePort{
{
Expand All @@ -611,7 +686,7 @@ func (c *MoodleController) createService(foo *operatorv1.Moodle) string {
//Type: apiv1.ServiceTypeNodePort,
Type: apiv1.ServiceTypeClusterIP,
//Type: apiv1.ServiceTypeLoadBalancer,
},
},*/
}

result1, err1 := serviceClient.Create(service)
Expand All @@ -637,6 +712,51 @@ func (c *MoodleController) createService(foo *operatorv1.Moodle) string {

return servicePort
}

func getServiceSpec(moodlePort int, deploymentName, domainName string) apiv1.ServiceSpec {

var serviceObj apiv1.ServiceSpec

if domainName == "" {
serviceObj = apiv1.ServiceSpec{
Ports: []apiv1.ServicePort{
{
Name: "my-port",
Port: int32(moodlePort),
TargetPort: apiutil.FromInt(moodlePort),
NodePort: int32(moodlePort),
Protocol: apiv1.ProtocolTCP,
},
},
Selector: map[string]string{
"app": deploymentName,
},
Type: apiv1.ServiceTypeNodePort,
//Type: apiv1.ServiceTypeClusterIP,
//Type: apiv1.ServiceTypeLoadBalancer,
}
} else {
serviceObj = apiv1.ServiceSpec{
Ports: []apiv1.ServicePort{
{
Name: "my-port",
Port: int32(moodlePort),
TargetPort: apiutil.FromInt(moodlePort),
//NodePort: int32(MOODLE_PORT),
Protocol: apiv1.ProtocolTCP,
},
},
Selector: map[string]string{
"app": deploymentName,
},
//Type: apiv1.ServiceTypeNodePort,
Type: apiv1.ServiceTypeClusterIP,
//Type: apiv1.ServiceTypeLoadBalancer,
}
}
return serviceObj
}

func (c *MoodleController) handlePluginDeployment(moodle *operatorv1.Moodle) (string, []string, []string, []string) {

installedPlugins := moodle.Status.InstalledPlugins
Expand Down Expand Up @@ -668,8 +788,8 @@ func (c *MoodleController) handlePluginDeployment(moodle *operatorv1.Moodle) (st
if len(supportedPlugins) > 0 {
podName = moodle.Status.PodName
namespace := getNamespace(moodle)
podname, _ := c.util.GetPodFullName(constants.TIMEOUT, podName, namespace)
erredPlugins = c.util.EnsurePluginsInstalled(moodle, supportedPlugins, podname, namespace, constants.PLUGIN_MAP)
//podname, _ := c.util.GetPodFullName(constants.TIMEOUT, podName, namespace)
erredPlugins = c.util.EnsurePluginsInstalled(moodle, supportedPlugins, podName, namespace, constants.PLUGIN_MAP)
}
if len(removeList) > 0 {
fmt.Println("MoodleController.go : ============= Plugin removal not implemented yet ===============")
Expand Down
2 changes: 1 addition & 1 deletion moodle/pkg/utils/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var PLUGIN_MAP = map[string]map[string]string{
"installFolder": "/var/www/html/local/",
},
"wiris": {
"downloadLink": "https://moodle.org/plugins/download.php/18916/filter_wiris_moodle36_2019020700.zip",
"downloadLink": "https://moodle.org/plugins/download.php/19765/filter_wiris_moodle37_2019061200.zip",
"installFolder": "/var/www/html/filter/",
},
}

0 comments on commit 9b633dc

Please sign in to comment.