This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from kabanero-io/aadeshpa-issue-132-merge-two…
…-tasks aadeshpa issue 132 merged build and deploy task
- Loading branch information
Showing
10 changed files
with
342 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
#Kabanero! on activate substitute CollectionId for text 'CollectionId' | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: CollectionId-build-push-deploy-task | ||
spec: | ||
inputs: | ||
resources: | ||
- name: git-source | ||
type: git | ||
params: | ||
- name: pathToDockerFile | ||
default: /workspace/extracted/Dockerfile | ||
- name: pathToContext | ||
default: /workspace/extracted | ||
- name: appsody-yaml-file-path | ||
default: $HOME/.appsody/.appsody.yaml | ||
- name: repository-name | ||
default: CollectionId | ||
- name: app-deploy-file-name | ||
default: app-deploy.yaml | ||
outputs: | ||
resources: | ||
- name: docker-image | ||
type: image | ||
steps: | ||
- name: extract | ||
securityContext: | ||
privileged: true | ||
image: appsody/appsody-buildah:0.5.0-buildah1.9.0 | ||
command: ["/bin/bash"] | ||
args: | ||
- -c | ||
- | | ||
echo "running appsody extract" | ||
appsody extract --buildah --target-dir /workspace/$gitsource -v | ||
echo "extract completed" | ||
ls -la /workspace/$gitsource | ||
cat /workspace/git-source/$(inputs.params.app-deploy-file-name) | ||
env: | ||
- name: gitsource | ||
value: git-source | ||
volumeMounts: | ||
- mountPath: /var/lib/containers | ||
name: varlibcontainers | ||
- name: validate-collection-is-active | ||
securityContext: | ||
privileged: true | ||
image: kabanero/validate-collection:0.1 | ||
command: ["/bin/bash"] | ||
args: | ||
- -c | ||
- "/validate.sh" | ||
env: | ||
- name: gitsource | ||
value: git-source | ||
- name: build | ||
securityContext: | ||
privileged: true | ||
image: appsody/appsody-buildah:0.5.0-buildah1.9.0 | ||
command: ["/bin/bash"] | ||
args: | ||
- -c | ||
- | | ||
echo "Checking for configmap value....DEFAULT_COLLECTION_IMAGE_REGISTRY_URL=$DEFAULT_COLLECTION_IMAGE_REGISTRY_URL" | ||
echo "appsody-yaml-file-path=$(inputs.params.appsody-yaml-file-path)" | ||
if [ -z "$DEFAULT_COLLECTION_IMAGE_REGISTRY_URL" ] | ||
then | ||
echo "DEFAULT_COLLECTION_IMAGE_REGISTRY_URL=$DEFAULT_COLLECTION_IMAGE_REGISTRY_URL given as input by user is empty, so using the registry for collection image download from $(inputs.params.appsody-yaml-file-path)" | ||
else | ||
if [ -f "$(inputs.params.appsody-yaml-file-path)" ] | ||
then | ||
echo "Appsody yaml file $(inputs.params.appsody-yaml-file-path) exists." | ||
else | ||
echo "Appsody yaml file $(inputs.params.appsody-yaml-file-path) does not exists, we are creating it by running appsody list command." | ||
appsody version | ||
fi | ||
#Replacing the container registry from index.docker.io to DEFAULT_COLLECTION_IMAGE_REGISTRY_URL for collection image download in the file inputs.params.appsody-yaml-file-path | ||
sed -i -e 's#images: .*$#images: $(DEFAULT_COLLECTION_IMAGE_REGISTRY_URL)#g' $(inputs.params.appsody-yaml-file-path) | ||
echo "sed command completed successfully" | ||
#Creating a cert for authentication of buildah login of the DEFAULT_COLLECTION_IMAGE_REGISTRY_URL registry url | ||
echo "HOST=$DEFAULT_COLLECTION_IMAGE_REGISTRY_URL" > cert-creation.sh | ||
echo "sudo mkdir -p /etc/docker/certs.d/\${HOST}" >> cert-creation.sh | ||
echo "openssl s_client -connect \${HOST} -servername \${HOST} 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/docker/certs.d/\${HOST}/ca.crt" >> cert-creation.sh | ||
if [[ ( -z "$DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_USERNAME" ) || ( -z "$DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_PASSWORD" ) ]] | ||
then | ||
echo "DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_USERNAME or DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_PASSWORD is empty ,Assumption is $DEFAULT_COLLECTION_IMAGE_REGISTRY_URL is internal registry, skipping the login to the registry" | ||
else | ||
echo "Both DEFAULT_COLLECTION_IMAGE_REGISTRY_URL and Secrets are provided" | ||
echo "Adding buildah login command to cert-creation.sh script" | ||
echo "buildah login -u $DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_USERNAME -p $DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_PASSWORD \${HOST}" >> cert-creation.sh | ||
fi | ||
chmod 755 cert-creation.sh | ||
./cert-creation.sh | ||
fi | ||
cd /workspace/$gitsource | ||
appsody build -t $(outputs.resources.docker-image.url) --buildah --buildah-options "--format=docker" | ||
env: | ||
- name: gitsource | ||
value: git-source | ||
- name: DEFAULT_COLLECTION_IMAGE_REGISTRY_URL | ||
valueFrom: | ||
configMapKeyRef: | ||
name: collection-image-registry-map | ||
key: default-collection-image-registry-url | ||
optional: true | ||
- name: DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: default-collection-image-registry-secret | ||
key: username | ||
optional: true | ||
- name: DEFAULT_COLLECTION_IMAGE_REGISTRY_SECRET_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: default-collection-image-registry-secret | ||
key: password | ||
optional: true | ||
volumeMounts: | ||
- mountPath: /var/lib/containers | ||
name: varlibcontainers | ||
- name: config-volume | ||
mountPath: /config | ||
- name: secret-volume | ||
mountPath: /etc/secret-volume | ||
- name: push | ||
securityContext: | ||
privileged: true | ||
image: appsody/appsody-buildah:0.5.0-buildah1.9.0 | ||
command: ['buildah', 'push', '--tls-verify=false', '$(outputs.resources.docker-image.url)', 'docker://$(outputs.resources.docker-image.url)'] | ||
env: | ||
- name: gitsource | ||
value: git-source | ||
volumeMounts: | ||
- mountPath: /var/lib/containers | ||
name: varlibcontainers | ||
- name: deploy-image | ||
image: kabanero/kabanero-utils:0.3.0 | ||
command: ['/bin/sh'] | ||
args: ['-c', 'find /workspace/git-source -name ${YAMLFILE} -type f|xargs kubectl apply -f'] | ||
env: | ||
- name: YAMLFILE | ||
value: $(inputs.params.app-deploy-file-name) | ||
volumes: | ||
- name: varlibcontainers | ||
emptyDir: {} | ||
- name: config-volume | ||
configMap: | ||
name: collection-image-registry-map | ||
optional: true | ||
- name: secret-volume | ||
secret: | ||
secretName: default-collection-image-registry-secret | ||
optional: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.