Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For windows #57

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG OS_RELEASE

FROM mcr.microsoft.com/windows/servercore:${OS_RELEASE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

RUN $url = 'https://cygwin.com/setup-x86_64.exe'; \
Write-Host ('Downloading {0} ...' -f $url); \
Invoke-WebRequest -Uri $url -OutFile 'C:/setup-x86_64.exe'; \
\
Write-Host 'Installing ...'; \
New-Item -ItemType directory -Path 'C:/tmp'; \
Start-Process "C:/setup-x86_64.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-q','-v','-n','-B','-R','C:/cygwin64','-l','C:/tmp','-s','http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2019/03/06/161558','-X','-P', 'default,curl,openssl'); \
\
Write-Host 'Removing ...'; \
Remove-Item -Path 'C:/tmp' -Force -Recurse -ErrorAction Ignore; \
\
Write-Host 'Verifying install ...'; \
Start-Process "C:/cygwin64/bin/cygcheck.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-c'); \
\
Write-Host 'Complete.';

RUN $ACL=Get-Acl -Path 'C:\'; \
Set-Acl -Path 'C:\cygwin64\' -AclObject $ACL

SHELL ["C:/cygwin64/bin/sh", "-l", "-c"]
WORKDIR C:/cygwin64/bin

RUN 'curl -o /usr/bin/kubectl.exe -L https://storage.googleapis.com/kubernetes-release/release/v1.22.0/bin/windows/amd64/kubectl.exe'
RUN 'chmod +x /usr/bin/kubectl.exe'

COPY cf-deploy-kubernetes.sh ../cf-deploy-kubernetes
COPY template.sh ../template.sh

RUN 'sed -i "s/\r$//" C:/cygwin64/cf-deploy-kubernetes'
RUN 'sed -i "s/\r$//" C:/cygwin64/template.sh'

LABEL owner=codefresh.io

ENTRYPOINT ["C:/cygwin64/bin/sh", "-l", "-c"]
10 changes: 5 additions & 5 deletions cf-deploy-kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fatal() {
readonly KUBECTL_ACTION=${KUBECTL_ACTION:-apply}
[[ $KUBECTL_ACTION =~ ^(apply|create|replace)$ ]] || fatal "KUBECTL_ACTION should be one of apply|create|replace "

deployment_file=${1:-deployment.yml}
deployment_file=${1:-C:/codefresh/volume/cf-generated/deployment.yml}
: ${KUBERNETES_NAMESPACE:=default}
: ${KUBERNETES_DEPLOYMENT_TIMEOUT:=120}

Expand Down Expand Up @@ -38,16 +38,16 @@ else
fi

#check the cluster version and decide which version of kubectl to use:
SERVER_VERSION=$(kubectl version --short=true | grep -i server | cut -c18-20 | tr -d .)
SERVER_VERSION=$(kubectl version --short=true --context "${KUBECONTEXT}" | grep -i server | cut -c18-20 | tr -d .)

if (( "$SERVER_VERSION" <= "16" )); then mv /usr/local/bin/kubectl1.6 /usr/local/bin/kubectl; fi
if (( "$SERVER_VERSION" <= "16" )); then mv /usr/local/bin/kubectl1.6 /usr/local/bin/kubectl; fi 2>/dev/null


[ ! -f "${deployment_file}" ] && echo "Couldn't find $deployment_file file at $(pwd)" && exit 1;


DEPLOYMENT_FILE=${deployment_file}-$(date '+%y-%m-%d_%H-%M-%S').yml
$(dirname $0)/template.sh "$deployment_file" > "$DEPLOYMENT_FILE" || fatal "Failed to apply deployment template on $deployment_file"
/template.sh "$deployment_file" > "$DEPLOYMENT_FILE" || fatal "Failed to apply deployment template on $deployment_file"


echo "---> Kubernetes objects to deploy in $deployment_file :"
Expand All @@ -66,5 +66,5 @@ kubectl --context "${KUBECONTEXT}" --namespace "${KUBERNETES_NAMESPACE}" $KUBECT

if [ -n "$DEPLOYMENT_NAME" ]; then
echo "---> Waiting for a successful deployment/${DEPLOYMENT_NAME} status to namespace ${KUBERNETES_NAMESPACE} ..."
timeout -s SIGTERM -t $KUBERNETES_DEPLOYMENT_TIMEOUT kubectl --context "${KUBECONTEXT}" --namespace "${KUBERNETES_NAMESPACE}" rollout status deployment/"${DEPLOYMENT_NAME}" || fatal "Deployment Failed"
timeout -s SIGTERM $KUBERNETES_DEPLOYMENT_TIMEOUT kubectl --context "${KUBECONTEXT}" --namespace "${KUBERNETES_NAMESPACE}" rollout status deployment/"${DEPLOYMENT_NAME}" || fatal "Deployment Failed"
fi