Skip to content

Commit

Permalink
Merge branch release-1.5 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
torredil committed Apr 19, 2022
1 parent 20b6dc3 commit 682fd3a
Show file tree
Hide file tree
Showing 85 changed files with 1,979 additions and 517 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG-0.x.md
Expand Up @@ -9,7 +9,7 @@

# v1.5.1
## Notable changes
* Address CVE ALAS-2021-1552
* Address CVE ALAS-2021-1552, ALAS2-2022-1736, ALAS2-2022-1738, ALAS2-2022-1743

# v1.5.0
### Misc.
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Expand Up @@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# See
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
# for info on BUILDPLATFORM, TARGETOS, TARGETARCH, etc.
FROM --platform=$BUILDPLATFORM golang:1.17 AS builder
WORKDIR /go/src/github.com/kubernetes-sigs/aws-ebs-csi-driver
COPY . .
ARG OS
ARG ARCH
RUN make $OS/$ARCH
ARG TARGETOS
ARG TARGETARCH
RUN OS=$TARGETOS ARCH=$TARGETARCH make $TARGETOS/$TARGETARCH

FROM amazonlinux:2 AS linux-amazon
RUN yum update -y && \
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Expand Up @@ -40,9 +40,11 @@ ALL_OS?=linux windows
ALL_ARCH_linux?=amd64 arm64
ALL_OSVERSION_linux?=amazon
ALL_OS_ARCH_OSVERSION_linux=$(foreach arch, $(ALL_ARCH_linux), $(foreach osversion, ${ALL_OSVERSION_linux}, linux-$(arch)-${osversion}))

ALL_ARCH_windows?=amd64
ALL_OSVERSION_windows?=1809 2004 20H2
ALL_OS_ARCH_OSVERSION_windows=$(foreach arch, $(ALL_ARCH_windows), $(foreach osversion, ${ALL_OSVERSION_windows}, windows-$(arch)-${osversion}))

ALL_OS_ARCH_OSVERSION=$(foreach os, $(ALL_OS), ${ALL_OS_ARCH_OSVERSION_${os}})

# split words on hyphen, access by 1-index
Expand All @@ -61,15 +63,18 @@ bin/aws-ebs-csi-driver.exe: | bin
CGO_ENABLED=0 GOOS=windows GOARCH=$(ARCH) go build -mod=vendor -ldflags ${LDFLAGS} -o bin/aws-ebs-csi-driver.exe ./cmd/

# Builds all linux images (not windows because it can't be exported with OUTPUT_TYPE=docker)
.PHONY: all
all: all-image-docker

# Builds all linux and windows images and pushes them
.PHONY: all-push
all-push: all-image-registry push-manifest

.PHONY: push-manifest
push-manifest: create-manifest
docker manifest push --purge $(IMAGE):$(TAG)

.PHONY: create-manifest
create-manifest:
# sed expression:
# LHS: match 0 or more not space characters
Expand All @@ -79,18 +84,19 @@ create-manifest:
# Only linux for OUTPUT_TYPE=docker because windows image cannot be exported
# "Currently, multi-platform images cannot be exported with the docker export type. The most common usecase for multi-platform images is to directly push to a registry (see registry)."
# https://docs.docker.com/engine/reference/commandline/buildx_build/#output
.PHONY: all-image-docker
all-image-docker: $(addprefix sub-image-docker-,$(ALL_OS_ARCH_OSVERSION_linux))
.PHONY: all-image-registry
all-image-registry: $(addprefix sub-image-registry-,$(ALL_OS_ARCH_OSVERSION))

sub-image-%:
$(MAKE) OUTPUT_TYPE=$(call word-hyphen,$*,1) OS=$(call word-hyphen,$*,2) ARCH=$(call word-hyphen,$*,3) OSVERSION=$(call word-hyphen,$*,4) image

.PHONY: image
image: .image-$(TAG)-$(OS)-$(ARCH)-$(OSVERSION)
.image-$(TAG)-$(OS)-$(ARCH)-$(OSVERSION):
docker buildx build \
--platform=$(OS)/$(ARCH) \
--build-arg OS=$(OS) \
--build-arg ARCH=$(ARCH) \
--progress=plain \
--target=$(OS)-$(OSVERSION) \
--output=type=$(OUTPUT_TYPE) \
Expand Down Expand Up @@ -126,6 +132,7 @@ bin/golangci-lint: | bin
kubeval: bin/kubeval
bin/kubeval -d deploy/kubernetes/base,deploy/kubernetes/cluster,deploy/kubernetes/overlays -i kustomization.yaml,crd_.+\.yaml,controller_add

.PHONY: mockgen
mockgen: bin/mockgen
./hack/update-gomock

Expand Down
2 changes: 2 additions & 0 deletions OWNERS
Expand Up @@ -9,6 +9,7 @@ approvers:
- ayberk
- AndyXiangLi
- vdhanan
- gtxu
reviewers:
- bertinatto
- jsafrane
Expand All @@ -20,3 +21,4 @@ reviewers:
- ayberk
- AndyXiangLi
- vdhanan
- gtxu
8 changes: 6 additions & 2 deletions charts/aws-ebs-csi-driver/templates/_helpers.tpl
Expand Up @@ -41,8 +41,12 @@ helm.sh/chart: {{ include "aws-ebs-csi-driver.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/component: csi-driver
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels }}
{{- end }}
{{- end -}}

{{/*
Expand All @@ -56,15 +60,15 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Convert the `--extra-volume-tags` command line arg from a map.
Convert the `--extra-tags` command line arg from a map.
*/}}
{{- define "aws-ebs-csi-driver.extra-volume-tags" -}}
{{- $result := dict "pairs" (list) -}}
{{- range $key, $value := .Values.controller.extraVolumeTags -}}
{{- $noop := printf "%s=%v" $key $value | append $result.pairs | set $result "pairs" -}}
{{- end -}}
{{- if gt (len $result.pairs) 0 -}}
{{- printf "%s=%s" "- --extra-volume-tags" (join "," $result.pairs) -}}
{{- printf "%s=%s" "- --extra-tags" (join "," $result.pairs) -}}
{{- end -}}
{{- end -}}

Expand Down
10 changes: 7 additions & 3 deletions charts/aws-ebs-csi-driver/templates/clusterrole-snapshotter.yaml
Expand Up @@ -9,9 +9,13 @@ rules:
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "list", "watch", "create", "update", "patch" ]
- apiGroups: [ "" ]
resources: [ "secrets" ]
verbs: [ "get", "list" ]
# Secret permission is optional.
# Enable it if your driver needs secret.
# For example, `csi.storage.k8s.io/snapshotter-secret-name` is set in VolumeSnapshotClass.
# See https://kubernetes-csi.github.io/docs/secrets-and-credentials.html for more details.
# - apiGroups: [ "" ]
# resources: [ "secrets" ]
# verbs: [ "get", "list" ]
- apiGroups: [ "snapshot.storage.k8s.io" ]
resources: [ "volumesnapshotclasses" ]
verbs: [ "get", "list", "watch" ]
Expand Down
6 changes: 5 additions & 1 deletion charts/aws-ebs-csi-driver/templates/controller.yaml
Expand Up @@ -57,6 +57,10 @@ spec:
topologySpreadConstraints:
{{- $constraints | toYaml | nindent 8 }}
{{- end }}
{{- with .Values.controller.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: ebs-plugin
image: {{ printf "%s:%s" .Values.image.repository (default (printf "v%s" .Chart.AppVersion) (.Values.image.tag | toString)) }}
Expand Down Expand Up @@ -189,7 +193,7 @@ spec:
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Capabilities.APIVersions.Has "snapshot.storage.k8s.io/v1" }}
{{- if or (.Capabilities.APIVersions.Has "snapshot.storage.k8s.io/v1beta1") (.Capabilities.APIVersions.Has "snapshot.storage.k8s.io/v1") }}
- name: csi-snapshotter
image: {{ printf "%s:%s" .Values.sidecars.snapshotter.image.repository .Values.sidecars.snapshotter.image.tag }}
imagePullPolicy: {{ default .Values.image.pullPolicy .Values.sidecars.snapshotter.image.pullPolicy }}
Expand Down
@@ -1,4 +1,8 @@
{{- if .Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }}
apiVersion: policy/v1
{{- else }}
apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
name: ebs-csi-controller
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
@@ -1,6 +1,6 @@
timeout: 3600s
steps:
- name: gcr.io/k8s-testimages/gcb-docker-gcloud:v20210722-085d930
- name: gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20211118-2f2d816b90
entrypoint: ./hack/prow.sh
env:
- GIT_TAG=${_GIT_TAG}
Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Expand Up @@ -51,6 +51,7 @@ func main() {
driver.WithVolumeAttachLimit(options.NodeOptions.VolumeAttachLimit),
driver.WithKubernetesClusterID(options.ControllerOptions.KubernetesClusterID),
driver.WithAwsSdkDebugLog(options.ControllerOptions.AwsSdkDebugLog),
driver.WithWarnOnInvalidTag(options.ControllerOptions.WarnOnInvalidTag),
)
if err != nil {
klog.Fatalln(err)
Expand Down
3 changes: 3 additions & 0 deletions cmd/options/controller_options.go
Expand Up @@ -35,11 +35,14 @@ type ControllerOptions struct {
KubernetesClusterID string
// flag to enable sdk debug log
AwsSdkDebugLog bool
// flag to warn on invalid tag, instead of returning an error
WarnOnInvalidTag bool
}

func (s *ControllerOptions) AddFlags(fs *flag.FlagSet) {
fs.Var(cliflag.NewMapStringString(&s.ExtraTags), "extra-tags", "Extra tags to attach to each dynamically provisioned resource. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'")
fs.Var(cliflag.NewMapStringString(&s.ExtraVolumeTags), "extra-volume-tags", "DEPRECATED: Please use --extra-tags instead. Extra volume tags to attach to each dynamically provisioned volume. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'")
fs.StringVar(&s.KubernetesClusterID, "k8s-tag-cluster-id", "", "ID of the Kubernetes cluster used for tagging provisioned EBS volumes (optional).")
fs.BoolVar(&s.AwsSdkDebugLog, "aws-sdk-debug-log", false, "To enable the aws sdk debug log level (default to false).")
fs.BoolVar(&s.WarnOnInvalidTag, "warn-on-invalid-tag", false, "To warn on invalid tags, instead of returning an error")
}
10 changes: 7 additions & 3 deletions deploy/kubernetes/base/clusterrole-snapshotter.yaml
Expand Up @@ -10,9 +10,13 @@ rules:
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "list", "watch", "create", "update", "patch" ]
- apiGroups: [ "" ]
resources: [ "secrets" ]
verbs: [ "get", "list" ]
# Secret permission is optional.
# Enable it if your driver needs secret.
# For example, `csi.storage.k8s.io/snapshotter-secret-name` is set in VolumeSnapshotClass.
# See https://kubernetes-csi.github.io/docs/secrets-and-credentials.html for more details.
# - apiGroups: [""]
# resources: ["secrets"]
# verbs: ["get", "list"]
- apiGroups: [ "snapshot.storage.k8s.io" ]
resources: [ "volumesnapshotclasses" ]
verbs: [ "get", "list", "watch" ]
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/base/controller.yaml
Expand Up @@ -28,7 +28,7 @@ spec:
operator: Exists
- operator: Exists
effect: NoExecute
tolerationSeconds: 300
tolerationSeconds: 300
containers:
- name: ebs-plugin
image: public.ecr.aws/ebs-csi-driver/aws-ebs-csi-driver:v1.5.3
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/overlays/stable/gcr/kustomization.yaml
Expand Up @@ -10,7 +10,7 @@ images:
- name: k8s.gcr.io/sig-storage/csi-attacher
newTag: v3.1.0
- name: k8s.gcr.io/sig-storage/livenessprobe
newTag: v2.2.0
newTag: v2.4.0
- name: k8s.gcr.io/sig-storage/csi-snapshotter
newTag: v3.0.3
- name: k8s.gcr.io/sig-storage/csi-resizer
Expand Down
5 changes: 4 additions & 1 deletion docs/README.md
Expand Up @@ -46,11 +46,14 @@ To help manage volumes in the aws account, CSI driver will automatically add tag
| TagKey | TagValue | sample | Description |
|------------------------|---------------------------|---------------------------------------------------------------------|---------------------|
| CSIVolumeName | pvcName | CSIVolumeName = pvc-a3ab0567-3a48-4608-8cb6-4e3b1485c808 | add to all volumes, for recording associated pvc id and checking if a given volume was already created so that ControllerPublish/CreateVolume is idempotent. |
| CSISnapshotName | volumeSnapshotContentName | CSISnapshotName = snapcontent-69477690-803b-4d3e-a61a-03c7b2592a76 | add to all snapshots, for recording associated VolumeSnapshot id and checking if a given snapshot was already created |
| CSIVolumeSnapshotName | volumeSnapshotContentName | CSIVolumeSnapshotName = snapcontent-69477690-803b-4d3e-a61a-03c7b2592a76 | add to all snapshots, for recording associated VolumeSnapshot id and checking if a given snapshot was already created |
| ebs.csi.aws.com/cluster| true | ebs.csi.aws.com/cluster = true | add to all volumes and snapshots, for allowing users to use a policy to limit csi driver's permission to just the resources it manages. |
| kubernetes.io/cluster/X| owned | kubernetes.io/cluster/aws-cluster-id-1 = owned | add to all volumes and snapshots if k8s-tag-cluster-id argument is set to X.|
| extra-key | extra-value | extra-key = extra-value | add to all volumes and snapshots if extraTags argument is set|


The CSI driver also supports passing tags through `StorageClass.parameters`. For more information, please refer to the [tagging doc](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/TAGGING.md).

## Driver Options
There are couple driver options that can be passed as arguments when starting driver container.

Expand Down

0 comments on commit 682fd3a

Please sign in to comment.