Skip to content

Commit

Permalink
Add version information to resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira committed Feb 15, 2024
1 parent 1b7c2a3 commit 2ef7c47
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.0.1
VERSION ?= 1.17.0

BUILD_TOOL ?= podman

Expand Down
2 changes: 2 additions & 0 deletions controllers/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type DeploymentConfig struct {
Schedule string
VolumeMountName string
PVCClaimName string
Version string
}

// createDeploymentObject returns a Deployment for the TrustyAI Service instance
Expand Down Expand Up @@ -54,6 +55,7 @@ func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context,
Schedule: strconv.Itoa(batchSize),
VolumeMountName: volumeMountName,
PVCClaimName: pvcName,
Version: Version,
}

var deployment *appsv1.Deployment
Expand Down
16 changes: 8 additions & 8 deletions controllers/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(deployment.Labels["app.kubernetes.io/name"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/instance"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/part-of"]).Should(Equal(componentName))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal(Version))

Expect(len(deployment.Spec.Template.Spec.Containers)).Should(Equal(2))
Expect(deployment.Spec.Template.Spec.Containers[0].Image).Should(Equal("quay.io/trustyai/trustyai-service:latest"))
Expand Down Expand Up @@ -121,7 +121,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app.kubernetes.io/instance"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/name"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/part-of"]).Should(Equal("trustyai"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

})
Expand Down Expand Up @@ -163,7 +163,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(deployment.Labels["app.kubernetes.io/name"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/instance"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/part-of"]).Should(Equal(componentName))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal(Version))

Expect(len(deployment.Spec.Template.Spec.Containers)).Should(Equal(2))
Expect(deployment.Spec.Template.Spec.Containers[0].Image).Should(Equal(serviceImage))
Expand Down Expand Up @@ -202,7 +202,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app.kubernetes.io/instance"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/name"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/part-of"]).Should(Equal("trustyai"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

})
Expand Down Expand Up @@ -350,7 +350,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(deployment.Labels["app.kubernetes.io/name"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/instance"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/part-of"]).Should(Equal(componentName))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal(Version))

WaitFor(func() error {
err := reconciler.reconcileOAuthService(ctx, instance)
Expand All @@ -370,7 +370,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app.kubernetes.io/instance"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/name"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/part-of"]).Should(Equal("trustyai"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

})
Expand Down Expand Up @@ -431,7 +431,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(deployment.Labels["app.kubernetes.io/name"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/instance"]).Should(Equal(defaultServiceName))
Expect(deployment.Labels["app.kubernetes.io/part-of"]).Should(Equal(componentName))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(deployment.Labels["app.kubernetes.io/version"]).Should(Equal(Version))

Expect(len(deployment.Spec.Template.Spec.Containers)).Should(Equal(2))
Expect(deployment.Spec.Template.Spec.Containers[0].Image).Should(Equal("quay.io/trustyai/trustyai-service:latest"))
Expand All @@ -455,7 +455,7 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app.kubernetes.io/instance"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/name"]).Should(Equal(instance.Name))
Expect(oauthService.Labels["app.kubernetes.io/part-of"]).Should(Equal("trustyai"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal("0.1.0"))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

}
Expand Down
2 changes: 2 additions & 0 deletions controllers/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ type OAuthConfig struct {

type ServiceTLSConfig struct {
Instance *trustyaiopendatahubiov1alpha1.TrustyAIService
Version string
}

// generateTrustyAIOAuthService defines the desired OAuth service object
func generateTrustyAIOAuthService(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (*corev1.Service, error) {

serviceTLSConfig := ServiceTLSConfig{
Instance: instance,
Version: Version,
}

var serviceTLS *corev1.Service
Expand Down
2 changes: 1 addition & 1 deletion controllers/service_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r *TrustyAIServiceReconciler) createServiceAccount(ctx context.Context, in
"app.kubernetes.io/name": serviceAccountName,
"app.kubernetes.io/instance": instance.Name,
"app.kubernetes.io/part-of": componentName,
"app.kubernetes.io/version": "0.1.0",
"app.kubernetes.io/version": Version,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions controllers/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ const (
type ServiceConfig struct {
Name string
Namespace string
Version string
}

func (r *TrustyAIServiceReconciler) reconcileService(ctx context.Context, cr *trustyaiopendatahubiov1alpha1.TrustyAIService) (*corev1.Service, error) {

serviceConfig := ServiceConfig{
Name: cr.Name,
Namespace: cr.Namespace,
Version: Version,
}

var service *corev1.Service
Expand Down
6 changes: 3 additions & 3 deletions controllers/templates/service/deployment.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
app.kubernetes.io/instance: {{ .Instance.Name }}
app.kubernetes.io/name: {{ .Instance.Name }}
app.kubernetes.io/part-of: trustyai
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: {{ .Version }}
spec:
replicas: 1
selector:
Expand All @@ -19,15 +19,15 @@ spec:
app.kubernetes.io/instance: {{ .Instance.Name }}
app.kubernetes.io/name: {{ .Instance.Name }}
app.kubernetes.io/part-of: trustyai
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: {{ .Version }}
template:
metadata:
labels:
app: {{ .Instance.Name }}
app.kubernetes.io/instance: {{ .Instance.Name }}
app.kubernetes.io/name: {{ .Instance.Name }}
app.kubernetes.io/part-of: trustyai
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: {{ .Version }}
annotations:
prometheus.io/path: /q/metrics
prometheus.io/scheme: http
Expand Down
4 changes: 2 additions & 2 deletions controllers/templates/service/service-internal.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
app.kubernetes.io/instance: {{ .Name }}
app.kubernetes.io/name: {{ .Name }}
app.kubernetes.io/part-of: trustyai
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: {{ .Version }}
spec:
ports:
- name: http
Expand All @@ -25,4 +25,4 @@ spec:
app.kubernetes.io/instance: {{ .Name }}
app.kubernetes.io/name: {{ .Name }}
app.kubernetes.io/part-of: trustyai
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: {{ .Version }}
2 changes: 1 addition & 1 deletion controllers/templates/service/service-tls.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
app.kubernetes.io/instance: {{ .Instance.Name }}
app.kubernetes.io/name: {{ .Instance.Name }}
app.kubernetes.io/part-of: trustyai
app.kubernetes.io/version: 0.1.0
app.kubernetes.io/version: {{ .Version }}
trustyai-service-name: {{ .Instance.Name }}
spec:
ports:
Expand Down
11 changes: 0 additions & 11 deletions controllers/trustyaiservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ type TrustyAIServiceReconciler struct {
//+kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;delete
//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=get;list;watch;create;update;delete

// getCommonLabels returns the service's common labels
func getCommonLabels(serviceName string) map[string]string {
return map[string]string{
"app": serviceName,
"app.kubernetes.io/name": serviceName,
"app.kubernetes.io/instance": serviceName,
"app.kubernetes.io/part-of": componentName,
"app.kubernetes.io/version": "0.1.0",
}
}

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down
5 changes: 5 additions & 0 deletions controllers/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package controllers

const (
Version = "1.17.0"
)

0 comments on commit 2ef7c47

Please sign in to comment.