Skip to content

Commit

Permalink
Fix labeling for resources managed by the Application controller so…
Browse files Browse the repository at this point in the history
… that ArgoCD can track resources properly
  • Loading branch information
Archisman-Mridha committed Feb 8, 2024
1 parent c4d2909 commit 893ca34
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
serviceAccountName: application-controller
containers:
- name: application-controller
image: ghcr.io/archisman-mridha/instagram-clone-application-controller:2420c7e7f17085462ddce5bfe7eeb37f1b308c4a
image: ghcr.io/archisman-mridha/instagram-clone-application-controller:0e132f1998e5208cc9c71ab60d2e70cc7d2940d3
resources:
requests:
memory: 128Mi
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/manifests/microservices/feeds/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Application
metadata:
name: feeds-microservice
namespace: microservices
labels:
app: feeds-microservice
app.kubernetes.io/instance: feeds-microservice

spec:
image: ghcr.io/archisman-mridha/instagram-clone-feeds-microservice:07db74b3dd4888026a2e852c6fca860157aa910a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Application
metadata:
name: followships-microservice
namespace: microservices
labels:
app: followships-microservice
app.kubernetes.io/instance: followships-microservice

spec:
image: ghcr.io/archisman-mridha/instagram-clone-followships-microservice:07db74b3dd4888026a2e852c6fca860157aa910a
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/manifests/microservices/gateway/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Application
metadata:
name: gateway-microservice
namespace: microservices
labels:
app: gateway-microservice
app.kubernetes.io/instance: gateway-microservice

spec:
image: ghcr.io/archisman-mridha/instagram-clone-gateway:2420c7e7f17085462ddce5bfe7eeb37f1b308c4a
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/manifests/microservices/posts/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Application
metadata:
name: posts-microservice
namespace: microservices
labels:
app: posts-microservice
app.kubernetes.io/instance: posts-microservice

spec:
image: ghcr.io/archisman-mridha/instagram-clone-posts-microservice:07db74b3dd4888026a2e852c6fca860157aa910a
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/manifests/microservices/profiles/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Application
metadata:
name: profiles-microservice
namespace: microservices
labels:
app: profiles-microservice
app.kubernetes.io/instance: profiles-microservice

spec:
image: ghcr.io/archisman-mridha/instagram-clone-profiles-microservice:07db74b3dd4888026a2e852c6fca860157aa910a
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/manifests/microservices/users/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Application
metadata:
name: users-microservice
namespace: microservices
labels:
app: users-microservice
app.kubernetes.io/instance: users-microservice

spec:
image: ghcr.io/archisman-mridha/instagram-clone-users-microservice:07db74b3dd4888026a2e852c6fca860157aa910a
Expand Down
14 changes: 11 additions & 3 deletions kubernetes/operators/application/pkg/controller/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ func (c *Controller) createOrUpdateDeployment(ctx context.Context, application *
podTemplateSpecObject := coreV1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"microservice": name,
"app": name,
"app.kubernetes.io/instance": name,
"app.kubernetes.io/part-of": name,
"app.kubernetes.io/managed-by": c.name,
},
},

Expand Down Expand Up @@ -365,6 +368,7 @@ func (c *Controller) createOrUpdateDeployment(ctx context.Context, application *
Namespace: namespace,
Labels: map[string]string{
"app": name,
"app.kubernetes.io/instance": name,
"app.kubernetes.io/part-of": name,
"app.kubernetes.io/managed-by": c.name,
},
Expand All @@ -389,7 +393,7 @@ func (c *Controller) createOrUpdateDeployment(ctx context.Context, application *

Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"microservice": name,
"app": name,
},
},

Expand Down Expand Up @@ -425,6 +429,8 @@ func (c *Controller) createOrUpdateHpa(ctx context.Context, application *v1alpha
Name: name,
Namespace: namespace,
Labels: map[string]string{
"app": name,
"app.kubernetes.io/instance": name,
"app.kubernetes.io/part-of": name,
"app.kubernetes.io/managed-by": c.name,
},
Expand Down Expand Up @@ -498,14 +504,16 @@ func (c *Controller) createOrUpdateService(ctx context.Context, application *v1a
Name: name,
Namespace: namespace,
Labels: map[string]string{
"app": name,
"app.kubernetes.io/instance": name,
"app.kubernetes.io/part-of": name,
"app.kubernetes.io/managed-by": c.name,
},
},

Spec: coreV1.ServiceSpec{
Selector: map[string]string{
"microservice": name,
"app": name,
},

Ports: servicePorts,
Expand Down

0 comments on commit 893ca34

Please sign in to comment.