Skip to content

Commit

Permalink
fix (jkube-kit/enricher) : Move ServiceAccount addition to ServiceAcc…
Browse files Browse the repository at this point in the history
…ountEnricher from handlers (eclipse-jkube#1758)

+ Currently `resources` > `serviceAccount` configuration option was being
  set in PodTemplateHandler, this worked for zero configuration option but
  not when user uses resource fragments. Move `serviceAccount` setting logic
  to ServiceAccountEnricher.
+ Rename IT `serviceaccount-via-groovy-dsl` -> `serviceaccounts-via-groovy-dsl` for clarity
+ Add IT `serviceaccountname-via-groovy-dsl` for `serviceAccount`
  resource configuration case

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Nov 7, 2022
1 parent dc10bdf commit e78198e
Show file tree
Hide file tree
Showing 26 changed files with 771 additions and 98 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ Usage:
* Fix #1684: Podman builds with errors are correctly processed and reported
* Fix #1888: KubernetesExtension has helper method to add image with builder

_**Note**_:
- `resources` > `serviceAccount` configuration would no longer create a new ServiceAccount. It would only add ServiceAccount reference to Deployment, Job etc. Users are advised to use `resources` > `serviceAccounts` configuration option in order to generate and add ServiceAccounts.

### 1.9.1 (2022-09-14)
* Fix #1747: Apply service doesn't attempt to create OpenShift Projects in Kubernetes clusters
* Fix #1758: ServiceAccount binding not being generated in Deployment

### 1.9.0 (2022-09-09)
* Fix #777: `k8s:build` with Dockerfile throws `Connection reset by peer` error on old docker daemons
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}"
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
id 'java'
}

group = 'org.eclipse.jkube.integration.tests.gradle'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
mavenCentral()
}

kubernetes {
offline = true
images {
image {
name = 'repository/serviceaccountname-via-groovy-dsl:latest'
build {
from = 'quay.io/jkube/jkube-java-11'
}
}
}
resources {
serviceAccount = "my-serviceaccount"
}
}

openshift {
offline = true
images {
image {
name = 'repository/serviceaccountname-via-groovy-dsl:latest'
build {
from = 'quay.io/jkube/jkube-java-11'
}
}
}
resources {
serviceAccount = "my-serviceaccount"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccountname-via-groovy-dsl
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
template:
metadata:
annotations:
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccountname-via-groovy-dsl
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
image: repository/serviceaccountname-via-groovy-dsl:latest
imagePullPolicy: IfNotPresent
name: repository-serviceaccountname-via-groovy-dsl
securityContext:
privileged: false
serviceAccountName: my-serviceaccount
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
app.openshift.io/vcs-ref: "@ignore@"
jkube.io/git-url: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccountname-via-groovy-dsl
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
app: serviceaccountname-via-groovy-dsl
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
strategy:
rollingParams:
timeoutSeconds: 3600
type: Rolling
template:
metadata:
annotations:
app.openshift.io/vcs-ref: "@ignore@"
jkube.io/git-url: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccountname-via-groovy-dsl
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: repository/serviceaccountname-via-groovy-dsl:latest
imagePullPolicy: IfNotPresent
name: repository-serviceaccountname-via-groovy-dsl
securityContext:
privileged: false
serviceAccountName: my-serviceaccount
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- repository-serviceaccountname-via-groovy-dsl
from:
kind: ImageStreamTag
name: serviceaccountname-via-groovy-dsl:latest
type: ImageChange
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccountname-via-groovy-dsl
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
template:
metadata:
annotations:
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
image: repository/serviceaccountname-via-groovy-dsl:latest
imagePullPolicy: IfNotPresent
name: repository-serviceaccountname-via-groovy-dsl
securityContext:
privileged: false
serviceAccountName: my-serviceaccount
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
app.openshift.io/vcs-ref: "@ignore@"
jkube.io/git-url: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccountname-via-groovy-dsl
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
app: serviceaccountname-via-groovy-dsl
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
strategy:
rollingParams:
timeoutSeconds: 3600
type: Rolling
template:
metadata:
annotations:
app.openshift.io/vcs-ref: "@ignore@"
jkube.io/git-url: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccountname-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: repository/serviceaccountname-via-groovy-dsl:latest
imagePullPolicy: IfNotPresent
name: repository-serviceaccountname-via-groovy-dsl
securityContext:
privileged: false
serviceAccountName: my-serviceaccount
triggers:
- type: ConfigChange
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2019 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at:
#
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

spec:
replicas: 1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kubernetes {
offline = true
images {
image {
name = 'repository/serviceaccount-via-groovy-dsl:latest'
name = 'repository/serviceaccounts-via-groovy-dsl:latest'
build {
from = 'quay.io/jkube/jkube-java-11'
}
Expand All @@ -34,7 +34,7 @@ openshift {
offline = true
images {
image {
name = 'repository/serviceaccount-via-groovy-dsl:latest'
name = 'repository/serviceaccounts-via-groovy-dsl:latest'
build {
from = 'quay.io/jkube/jkube-java-11'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ items:
kind: ServiceAccount
metadata:
labels:
app: serviceaccount-via-groovy-dsl
app: serviceaccounts-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
Expand All @@ -19,17 +19,17 @@ items:
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccount-via-groovy-dsl
app: serviceaccounts-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
name: serviceaccount-via-groovy-dsl
name: serviceaccounts-via-groovy-dsl
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: serviceaccount-via-groovy-dsl
app: serviceaccounts-via-groovy-dsl
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
template:
Expand All @@ -39,7 +39,7 @@ items:
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: serviceaccount-via-groovy-dsl
app: serviceaccounts-via-groovy-dsl
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.integration.tests.gradle
Expand All @@ -54,9 +54,9 @@ items:
valueFrom:
fieldRef:
fieldPath: metadata.name
image: repository/serviceaccount-via-groovy-dsl:latest
image: repository/serviceaccounts-via-groovy-dsl:latest
imagePullPolicy: IfNotPresent
name: repository-serviceaccount-via-groovy-dsl
name: repository-serviceaccounts-via-groovy-dsl
securityContext:
privileged: false
serviceAccountName: my-serviceaccount

0 comments on commit e78198e

Please sign in to comment.