Skip to content

Commit

Permalink
Add version information to resources (trustyai-explainability#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira authored Feb 15, 2024
1 parent da1cff5 commit 65fde44
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 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 @@ -36,6 +36,7 @@ type DeploymentConfig struct {
VolumeMountName string
PVCClaimName string
CustomCertificatesBundle CustomCertificatesBundle
Version string
}

// createDeploymentObject returns a Deployment for the TrustyAI Service instance
Expand Down Expand Up @@ -64,6 +65,7 @@ func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context,
VolumeMountName: volumeMountName,
PVCClaimName: pvcName,
CustomCertificatesBundle: caBunble,
Version: Version,
}

var deployment *appsv1.Deployment
Expand Down
24 changes: 12 additions & 12 deletions controllers/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,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 @@ -122,8 +122,8 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app"]).Should(Equal(instance.Name))
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/part-of"]).Should(Equal(componentName))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

})
Expand Down Expand Up @@ -167,7 +167,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 @@ -205,8 +205,8 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app"]).Should(Equal(instance.Name))
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/part-of"]).Should(Equal(componentName))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

})
Expand Down Expand Up @@ -463,7 +463,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, caBundle)
Expand All @@ -482,8 +482,8 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app"]).Should(Equal(instance.Name))
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/part-of"]).Should(Equal(componentName))
Expect(oauthService.Labels["app.kubernetes.io/version"]).Should(Equal(Version))
Expect(oauthService.Labels["trustyai-service-name"]).Should(Equal(instance.Name))

})
Expand Down Expand Up @@ -546,7 +546,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 @@ -569,8 +569,8 @@ var _ = Describe("TrustyAI operator", func() {
Expect(oauthService.Labels["app"]).Should(Equal(instance.Name))
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/part-of"]).Should(Equal(componentName))
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 @@ -23,6 +23,7 @@ type OAuthConfig struct {
type ServiceTLSConfig struct {
Instance *trustyaiopendatahubiov1alpha1.TrustyAIService
CustomCertificatesBundle CustomCertificatesBundle
Version string
}

// generateTrustyAIOAuthService defines the desired OAuth service object
Expand All @@ -31,6 +32,7 @@ func generateTrustyAIOAuthService(ctx context.Context, instance *trustyaiopendat
serviceTLSConfig := ServiceTLSConfig{
Instance: instance,
CustomCertificatesBundle: caBundle,
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 @@ -12,7 +12,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 65fde44

Please sign in to comment.