Skip to content

Commit 3358f2d

Browse files
author
test
committed
minor fixes
1 parent 4fc72b1 commit 3358f2d

File tree

5 files changed

+37
-16
lines changed

5 files changed

+37
-16
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ metadata:
3737
name: picsum
3838
namespace: default
3939
spec:
40-
image: "zreigz/dash-picsum:0.1.0"
41-
containerPort: 8050
4240
replicas: 1
41+
container:
42+
image: "zreigz/dash-picsum:0.1.0"
43+
containerPort: 8050
44+
ingress:
45+
path: "/picsum"
4346
```
4447
45-
The controller will create Deployment and Service with the DashApplication name: `picsum`
48+
The controller will create Deployment, Service and Ingress with the DashApplication name: `picsum`

example/echo_app.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: dash.plural.sh/v1alpha1
2+
kind: DashApplication
3+
metadata:
4+
name: echo
5+
namespace: default
6+
spec:
7+
replicas: 1
8+
container:
9+
image: "hashicorp/http-echo:0.2.3"
10+
containerPort: 5678
11+
args:
12+
- "-text=foo"
13+
ingress:
14+
path: "/echo"

pkg/controller/dash_controller.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
5959
}
6060
}
6161

62-
ingress := &networkingv1.Ingress{}
63-
if err := r.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, ingress); err != nil {
64-
if !apierrors.IsNotFound(err) {
65-
return ctrl.Result{}, err
66-
}
67-
if dashApp.Spec.Ingress != nil {
62+
if dashApp.Spec.Ingress != nil {
63+
ingress := &networkingv1.Ingress{}
64+
if err := r.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, ingress); err != nil {
65+
if !apierrors.IsNotFound(err) {
66+
return ctrl.Result{}, err
67+
}
68+
6869
log.Info("create ingress")
6970
ingress = genIngress(dashApp)
7071
if err := r.Create(ctx, ingress); err != nil {
@@ -169,10 +170,11 @@ func genDeployment(dashApp *dashv1alpha1.DashApplication) *appsv1.Deployment {
169170
Spec: corev1.PodSpec{
170171
Containers: []corev1.Container{
171172
{
172-
Name: name,
173-
Image: dashApp.Spec.Container.Image,
174-
Args: dashApp.Spec.Container.Args,
175-
Command: dashApp.Spec.Container.Command,
173+
Name: name,
174+
ImagePullPolicy: corev1.PullAlways,
175+
Image: dashApp.Spec.Container.Image,
176+
Args: dashApp.Spec.Container.Args,
177+
Command: dashApp.Spec.Container.Command,
176178
Ports: []corev1.ContainerPort{
177179
{
178180
ContainerPort: dashApp.Spec.Container.ContainerPort,

resources/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ spec:
2222
serviceAccountName: dash-controller-sa
2323
containers:
2424
- name: dash-controller
25-
image: ghcr.io/pluralsh/dash-controller:0.0.3
25+
image: ghcr.io/pluralsh/dash-controller:0.0.4
2626
imagePullPolicy: Always

resources/rbac.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ rules:
1111
resources: ["dashapplications", "dashapplications/status"]
1212
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
1313
- apiGroups: [""]
14-
resources: ["events", "services", "ingresses"]
14+
resources: ["events", "services"]
1515
verbs: ["list", "watch", "create", "update", "patch", "get", "patch"]
1616
- apiGroups: ["apps"]
1717
resources: ["deployments"]
1818
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
19-
19+
- apiGroups: ["networking.k8s.io"]
20+
resources: ["ingresses"]
21+
verbs: ["get", "list", "watch", "update", "create", "delete", "patch"]
2022
---
2123
kind: ClusterRoleBinding
2224
apiVersion: rbac.authorization.k8s.io/v1

0 commit comments

Comments
 (0)