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

Csi proxy image #203

Merged
merged 6 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
42 changes: 42 additions & 0 deletions .github/workflows/csi-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: csi-proxy

on:
push:
branches: [ master ]
paths:
- hostprocess/csi-proxy/VERSION
workflow_dispatch:
pull_request:
paths:
- hostprocess/csi-proxy/**
branchs:
- master

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: login to GitHub container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set 'version' for ci
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "version=ci" >> $GITHUB_ENV
- name: set 'version' for release
if: ${{ github.event_name != 'pull_request' }}
run: |
export version=$(cat ./hostprocess/csi-proxy/VERSION)
echo "version=$version" >> $GITHUB_ENV
- name: build image
run: |
cd hostprocess/csi-proxy
./build.sh --push
jsturtevant marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions hostprocess/csi-proxy/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG REGISTRY=mcr.microsoft.com/windows
ARG WINDOWS_BASE_IMAGE=nanoserver
ARG WINDOWS_VERSION=1809

FROM --platform=linux/amd64 golang:1.16 as builder
ARG CSI_PROXY_VERSION=v1.0.2
RUN git clone https://github.com/kubernetes-csi/csi-proxy.git /go/csi-proxy &&\
cd /go/csi-proxy &&\
git checkout tags/${CSI_PROXY_VERSION} &&\
make build

FROM ${REGISTRY}/${WINDOWS_BASE_IMAGE}:${WINDOWS_VERSION}
COPY --from=builder /go/csi-proxy/bin/csi-proxy.exe /csi-proxy.exe
ENV PATH="C:\Windows\system32;C:\Windows;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;"
Copy link

@zhiweiv zhiweiv Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the env issue mentioned in https://github.com/kubernetes/kubernetes/blob/master/build/pause/Dockerfile_windows#L26-L28 has been fixed long ago, is this sill needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might not be.

ENTRYPOINT ["csi-proxy.exe", "-v", "4"]
9 changes: 9 additions & 0 deletions hostprocess/csi-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CSI-proxy

Runs [csi-proxy](https://github.com/kubernetes-csi/csi-proxy) on Windows nodes as a hostprocess container.

## Deploy

``` bash
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/sig-windows-tools/master/hostprocess/csi-proxy/csi-proxy.yaml
```
1 change: 1 addition & 0 deletions hostprocess/csi-proxy/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.2
61 changes: 61 additions & 0 deletions hostprocess/csi-proxy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
set -e

for i in "$@"; do
case $i in
--push)
push="1"
shift
;;
*)
;;
esac
done

if [[ -z "${version}" ]]; then
echo "Required env var 'version' is not set"
exit 1
fi
echo "Using version ${version}"

output="type=docker,dest=./export.tar"

if [[ "$push" == "1" ]]; then
output="type=registry"
fi

repository=${repository:-"ghcr.io/kubernetes-sigs/sig-windows"}

set -x

docker buildx create --name img-builder --use --platform windows/amd64
trap 'docker buildx rm img-builder' EXIT


declare -a win_vers=("1809" "ltsc2022")

manifest_entries=""

# Build container images with buildx
for win_ver in "${win_vers[@]}"; do
docker buildx build --platform windows/amd64 --output=$output -f Dockerfile.windows --build-arg=WINDOWS_VERSION=$win_ver -t ${repository}/csi-proxy:${version}-$win_ver .

manifest_entries="$manifest_entries ${repository}/csi-proxy:${version}-$win_ver"
done

if [[ $push != "1" ]]; then
exit
fi

# Create manifest
docker manifest create ${repository}/csi-proxy:${version} $manifest_entries

# Annotate manifests
for win_ver in "${win_vers[@]}"; do
os_ver=$(docker manifest inspect mcr.microsoft.com/windows/nanoserver:${win_ver} | grep "os.version" | head -n 1 | awk -F\" '{print $4}')
docker manifest annotate --os windows --arch amd64 --os-version $os_ver $repository/csi-proxy:$version $repository/csi-proxy:$version-$win_ver
done

docker manifest inspect $repository/csi-proxy:$version

docker manifest push ${repository}/csi-proxy:${version}
24 changes: 24 additions & 0 deletions hostprocess/csi-proxy/csi-proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: csi-proxy
namespace: kube-system
spec:
selector:
matchLabels:
name: csi-proxy
template:
metadata:
labels:
name: csi-proxy
spec:
nodeSelector:
"kubernetes.io/os": windows
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
hostNetwork: true
containers:
- name: csi-proxy
image: ghcr.io/kubernetes-sigs/sig-windows/csi-proxy:v1.0.2