Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
test committed Oct 24, 2022
1 parent 4fc72b1 commit 3358f2d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ metadata:
name: picsum
namespace: default
spec:
image: "zreigz/dash-picsum:0.1.0"
containerPort: 8050
replicas: 1
container:
image: "zreigz/dash-picsum:0.1.0"
containerPort: 8050
ingress:
path: "/picsum"
```
The controller will create Deployment and Service with the DashApplication name: `picsum`
The controller will create Deployment, Service and Ingress with the DashApplication name: `picsum`
14 changes: 14 additions & 0 deletions example/echo_app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: dash.plural.sh/v1alpha1
kind: DashApplication
metadata:
name: echo
namespace: default
spec:
replicas: 1
container:
image: "hashicorp/http-echo:0.2.3"
containerPort: 5678
args:
- "-text=foo"
ingress:
path: "/echo"
22 changes: 12 additions & 10 deletions pkg/controller/dash_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
}
}

ingress := &networkingv1.Ingress{}
if err := r.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, ingress); err != nil {
if !apierrors.IsNotFound(err) {
return ctrl.Result{}, err
}
if dashApp.Spec.Ingress != nil {
if dashApp.Spec.Ingress != nil {
ingress := &networkingv1.Ingress{}
if err := r.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, ingress); err != nil {
if !apierrors.IsNotFound(err) {
return ctrl.Result{}, err
}

log.Info("create ingress")
ingress = genIngress(dashApp)
if err := r.Create(ctx, ingress); err != nil {
Expand Down Expand Up @@ -169,10 +170,11 @@ func genDeployment(dashApp *dashv1alpha1.DashApplication) *appsv1.Deployment {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: name,
Image: dashApp.Spec.Container.Image,
Args: dashApp.Spec.Container.Args,
Command: dashApp.Spec.Container.Command,
Name: name,
ImagePullPolicy: corev1.PullAlways,
Image: dashApp.Spec.Container.Image,
Args: dashApp.Spec.Container.Args,
Command: dashApp.Spec.Container.Command,
Ports: []corev1.ContainerPort{
{
ContainerPort: dashApp.Spec.Container.ContainerPort,
Expand Down
2 changes: 1 addition & 1 deletion resources/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ spec:
serviceAccountName: dash-controller-sa
containers:
- name: dash-controller
image: ghcr.io/pluralsh/dash-controller:0.0.3
image: ghcr.io/pluralsh/dash-controller:0.0.4
imagePullPolicy: Always
6 changes: 4 additions & 2 deletions resources/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ rules:
resources: ["dashapplications", "dashapplications/status"]
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
- apiGroups: [""]
resources: ["events", "services", "ingresses"]
resources: ["events", "services"]
verbs: ["list", "watch", "create", "update", "patch", "get", "patch"]
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]

- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down

0 comments on commit 3358f2d

Please sign in to comment.