-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Crane UI + Tekton Integration Enhancement Updates (#35)
* feat: update clustertasks to integrate with UI The purpose of this change is to align with what is described in konveyor/enhancements#59 only to the extent that a demonstration of "Stateless App Migration" is possible. This will likely break our examples so it should not be merged into 'main' until stabilized. * chore: move kustomize manifests to config * chore: update examples based on new paths Now that all of the ClusterTasks have been updated based on [the tekton ui integration enhancement](https://github.com/konveyor/enhancements/tree/master/enhancements/crane-2.0/tekton-ui-integration), and some issues were discovered with handling of defaults, this commit attempts to make all of the changes functional. That means, after this commit all examples should integrate with the ClusterTasks as implemented. * chore: update hack dir * chore: remove personal container image references * docs: update descriptions to be more meaningful
- Loading branch information
Showing
29 changed files
with
354 additions
and
271 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
FROM registry.ci.openshift.org/openshift/release:golang-1.16 as crane-bin | ||
|
||
FROM registry.ci.openshift.org/openshift/release:golang-1.17 as crane-bin | ||
ENV GOFLAGS "-mod=mod" | ||
WORKDIR /go/src/github.com/konveyor/crane | ||
|
||
RUN git clone https://github.com/konveyor/crane.git . | ||
RUN go build -a -o /build/crane main.go | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi:latest | ||
FROM registry.redhat.io/openshift4/ose-cli:latest as cli-bin | ||
COPY ./config /config | ||
RUN curl -sL "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert" > /usr/local/bin/kubectl-convert && \ | ||
chmod +x /usr/local/bin/kubectl-convert | ||
RUN curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.4.1/kustomize_v4.4.1_linux_amd64.tar.gz" | \ | ||
tar xvzf - -C /usr/local/bin/ kustomize | ||
RUN kustomize build /config/default > /deploy.yaml | ||
|
||
FROM registry.redhat.io/ubi8/ubi:latest | ||
COPY --from=crane-bin /build/crane /usr/local/bin/crane | ||
COPY --from=cli-bin /usr/bin/oc /usr/bin/oc | ||
COPY --from=cli-bin /usr/bin/kubectl /usr/bin/kubectl | ||
COPY --from=cli-bin /usr/local/bin/kustomize /usr/local/bin/kustomize | ||
COPY --from=cli-bin /usr/local/bin/kubectl-convert /usr/local/bin/kubectl-convert | ||
COPY --from=cli-bin /deploy.yaml /deploy.yaml | ||
|
||
COPY --from=crane-bin /build/crane /crane | ||
RUN /crane plugin-manager add OpenshiftPlugin | ||
RUN crane plugin-manager add OpenShiftPlugin --version v0.0.3 | ||
|
||
# Helpful tools | ||
# TODO(djzager): Determine want can stay and what must go | ||
RUN curl -sL "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz" | \ | ||
tar xvzf - -C /usr/bin/ oc kubectl | ||
RUN curl -sL "https://github.com/mikefarah/yq/releases/download/v4.16.1/yq_linux_amd64.tar.gz" | \ | ||
tar xvzf - -C /usr/bin/ ./yq_linux_amd64 && \ | ||
mv /usr/bin/yq_linux_amd64 /usr/bin/yq | ||
RUN curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.4.1/kustomize_v4.4.1_linux_amd64.tar.gz" | \ | ||
tar xvzf - -C /usr/bin/ kustomize | ||
RUN dnf -y install git | ||
|
||
ENTRYPOINT ["/crane"] | ||
ENTRYPOINT ["/usr/local/bin/crane"] |
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,50 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: ClusterTask | ||
metadata: | ||
name: crane-kubeconfig-generator | ||
annotations: | ||
description: | | ||
This Task is responsible for taking a secret with keys `url` and `token`, | ||
logging into the cluster using `oc login`, renaming the context, and | ||
saving the result in the kubeconfig workspace. | ||
The idea is that subsequent Tasks in a Pipeline or PipelineRun could | ||
reference this task first to populate a kubeconfig based on cluster | ||
auth stored in a secret. | ||
spec: | ||
params: | ||
- name: cluster-secret | ||
type: string | ||
description: | | ||
The name of the secret holding cluster API Server URL and Token. | ||
- name: context-name | ||
type: string | ||
description: | | ||
The name to give the context. | ||
steps: | ||
- name: crane-export | ||
image: quay.io/konveyor/crane-runner:latest | ||
script: | | ||
export KUBECONFIG=$(workspaces.kubeconfig.path)/kubeconfig | ||
set +x | ||
oc login --insecure-skip-tls-verify --server=$CLUSTER_URL --token=$CLUSTER_TOKEN | ||
set -x | ||
kubectl config rename-context "$(kubectl config current-context)" "$(params.context-name)" | ||
env: | ||
- name: CLUSTER_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: $(params.cluster-secret) | ||
key: url | ||
- name: CLUSTER_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: $(params.cluster-secret) | ||
key: token | ||
workspaces: | ||
- name: kubeconfig | ||
readOnly: false | ||
description: | | ||
Where the generated kubeconfig will be saved. |
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,52 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: ClusterTask | ||
metadata: | ||
name: crane-kustomize-init | ||
annotations: | ||
description: | | ||
Initialize a kustomization.yaml for the manifests generated in crane-apply. | ||
spec: | ||
params: | ||
- name: source-namespace | ||
type: string | ||
description: Source namespace from export. | ||
- name: labels | ||
type: string | ||
description: Add one or more labels | ||
default: "" | ||
- name: name-prefix | ||
type: string | ||
description: Set the namePrefix field in the kustomization file. | ||
default: "" | ||
- name: namespace | ||
type: string | ||
description: Sets the value of the namespace field in the kustomization file. | ||
default: "" | ||
- name: name-suffix | ||
type: string | ||
description: Set the nameSuffix field in the kustomization file. | ||
default: "" | ||
steps: | ||
- name: kustomize-namespace | ||
image: quay.io/konveyor/crane-runner:latest | ||
script: | | ||
# Copy apply resources into kustomize workspace | ||
cp -r "$(workspaces.apply.path)/resources/$(params.source-namespace)/." "$(workspaces.kustomize.path)" | ||
pushd "$(workspaces.kustomize.path)" | ||
kustomize init --autodetect \ | ||
--labels "$(params.labels)" \ | ||
--nameprefix "$(params.name-prefix)" \ | ||
--namespace "$(params.namespace)" \ | ||
--namesuffix "$(params.name-suffix)" | ||
kustomize build | ||
popd | ||
find "$(workspaces.kustomize.path)" | ||
workspaces: | ||
- name: apply | ||
description: | | ||
This is the folder where the results from crane-apply are stored. | ||
mountPath: /var/crane/apply | ||
- name: kustomize | ||
description: | | ||
This is where the kustomize related manifests will be saved. |
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,89 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: ClusterTask | ||
metadata: | ||
name: crane-transfer-pvc | ||
annotations: | ||
description: | | ||
Sync's a single PVC from source to destination cluster | ||
spec: | ||
params: | ||
- name: source-context | ||
type: string | ||
description: | | ||
The name of the context from kubeconfig representing the source | ||
cluster. | ||
You can get this information in your current environment using | ||
`kubectl config get-contexts` to describe your one or many | ||
contexts. | ||
- name: source-namespace | ||
type: string | ||
description: | | ||
The source cluster namespace in which pvc is synced. | ||
- name: source-pvc-name | ||
type: string | ||
description: | | ||
The name of the pvc to be synced from source cluster. | ||
- name: dest-context | ||
type: string | ||
description: | | ||
The name of the context from kubeconfig representing the destination | ||
cluster. | ||
You can get this information in your current environment using | ||
`kubectl config get-contexts` to describe your one or many | ||
contexts. | ||
- name: dest-pvc-name | ||
type: string | ||
description: | | ||
The name to give pvc in destination cluster. | ||
default: "" | ||
- name: dest-namespace | ||
type: string | ||
description: | | ||
The source cluster namespace in which pvc is synced. | ||
default: "" | ||
- name: dest-storage-class-name | ||
type: string | ||
description: | | ||
The name of the storage class to use in the destination cluster. | ||
default: "" | ||
- name: dest-pvc-capacity | ||
type: string | ||
description: | | ||
Size of the destination volume to create. | ||
default: "" | ||
- name: endpoint-type | ||
type: string | ||
description: | | ||
The name of the networking endpoint to be used for ingress traffic in the destination cluster | ||
default: "" | ||
steps: | ||
- name: crane-transfer-pvc | ||
image: quay.io/konveyor/crane-runner:latest | ||
script: | | ||
crane transfer-pvc \ | ||
--source-context=$(params.source-context) \ | ||
--destination-context=$(params.dest-context) \ | ||
--pvc-name $(params.source-pvc-name):$(params.dest-pvc-name) \ | ||
--pvc-namespace $(params.source-namespace):$(params.dest-namespace) \ | ||
--dest-pvc-storage-class-name $(params.dest-storage-class-name) \ | ||
--pvc-requests-storage $(params.dest-pvc-capacity) \ | ||
--endpoint $(params.endpoint-type) | ||
env: | ||
- name: KUBECONFIG | ||
value: $(workspaces.kubeconfig.path)/kubeconfig | ||
- name: DEST_PVC_NAME | ||
value: $(params.dest-pvc-name) | ||
- name: DEST_NAMESPACE | ||
value: $(params.dest-namespace) | ||
- name: DEST_STORAGE_CLASS_NAME | ||
value: $(params.dest-storage-class-name) | ||
- name: DEST_PVC_CAPACITY | ||
value: $(params.dest-pvc-capacity) | ||
- name: ENDPOINT_TYPE | ||
value: $(params.endpoint-type) | ||
workspaces: | ||
- name: kubeconfig | ||
description: | | ||
The kubeconfig for accessing the source cluster. |
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.