Skip to content

Commit

Permalink
add manifests for kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveenrajmani committed Sep 25, 2024
1 parent c657af7 commit 1c89522
Show file tree
Hide file tree
Showing 50 changed files with 4,429 additions and 0 deletions.
119 changes: 119 additions & 0 deletions generate-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash
# This file is part of MinIO DirectPV
# Copyright (c) 2024 MinIO, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

ME=$(basename "$0"); export ME
cd "$(dirname "$0")" || exit 255

set -o errexit
set -o nounset
set -o pipefail

declare BUILD_VERSION KUBECTL_DIRECTPV KUSTOMIZE

function init() {
if [ "$#" -ne 1 ]; then
cat <<EOF
USAGE:
${ME} <VERSION>
EXAMPLE:
$ ${ME} 4.1.4
EOF
exit 255
fi

# assign after trimming 'v'
BUILD_VERSION="${1/v/}"

kubectl_directpv="kubectl-directpv_${BUILD_VERSION}_$(go env GOOS)_$(go env GOARCH)"
KUBECTL_DIRECTPV="${PWD}/${kubectl_directpv}"
if [ ! -f "${KUBECTL_DIRECTPV}" ]; then
echo "Downloading ${kubectl_directpv}"
curl --silent --location --insecure --fail --output "${kubectl_directpv}" "https://github.com/minio/directpv/releases/download/v${BUILD_VERSION}/${kubectl_directpv}"
chmod a+x "${kubectl_directpv}"
fi

if which kustomize >/dev/null 2>&1; then
KUSTOMIZE=kustomize
fi
if [ -f ./kustomize ]; then
KUSTOMIZE="${PWD}/kustomize"
fi
if [ -z "${KUSTOMIZE=}" ]; then
KUSTOMIZE="${PWD}/kustomize"
echo "Downloading kustomize"
release=$(curl -sfL "https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest" | awk '/tag_name/ { print substr($2, 12, length($2)-13) }')
curl --silent --location --insecure --fail "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${release}/kustomize_${release}_$(go env GOOS)_$(go env GOARCH).tar.gz" | tar -zxf -
fi
}

function git_commit() {
case "$(git describe --always --dirty)" in
*dirty)
git commit --quiet --all -m "$*"
git push --quiet
;;
esac
}

function update_resources() {
path="resources/base"
declare directpv_args
echo "$@"
for arg in "$@"; do
if [ "${arg}" == "--legacy" ]; then
path="resources/legacy/base"
elif [ "${arg}" == "--openshift" ]; then
path="resources/openshift/base"
fi
directpv_args+=("${arg}")
done

declare -A resources
"${KUBECTL_DIRECTPV}" install "${directpv_args[@]}" -o yaml | sed -e 's/^---/~~~/g' | awk '{f="file" NR; print $0 > f}' RS='~~~'
for file in file*; do
name=$(awk '/^kind:/ { print $NF }' "${file}")
if [ "${name}" == "CustomResourceDefinition" ]; then
name=$(awk '/^ name:/ { print $NF }' "${file}")
fi
if [[ -v "resources[$name]" ]]; then
name+=-$(awk '/^ name:/ { print $NF }' "${file}")
fi
if [ -n "$name" ]; then
resources["$name"]=""
fi
if [ -n "${name}" ]; then
mv "${file}" "${PWD}/${path}/${name}.yaml"
else
rm "${file}"
fi
done

git_commit "Updated resources for v${BUILD_VERSION}"
}

function main() {
rm -rf resources/base/*
update_resources
rm -rf resources/legacy/base/*
update_resources --legacy
rm -rf resources/openshift/base/*
update_resources --openshift
}

init "$@"
main "$@"
21 changes: 21 additions & 0 deletions resources/base/CSIDriver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
annotations:
directpv.min.io/plugin-version: v4.1.4
creationTimestamp: null
labels:
application-name: directpv.min.io
application-type: CSIDriver
directpv.min.io/created-by: kubectl-directpv
directpv.min.io/version: v1beta1
name: directpv-min-io
spec:
attachRequired: false
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
- Ephemeral


173 changes: 173 additions & 0 deletions resources/base/ClusterRole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
directpv.min.io/plugin-version: v4.1.4
rbac.authorization.kubernetes.io/autoupdate: "true"
creationTimestamp: null
labels:
application-name: directpv.min.io
application-type: CSIDriver
directpv.min.io/created-by: kubectl-directpv
directpv.min.io/version: v1beta1
name: directpv-min-io
rules:
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- create
- delete
- get
- list
- patch
- watch
- apiGroups:
- ""
resources:
- persistentvolumeclaims/status
verbs:
- patch
- apiGroups:
- policy
resources:
- podsecuritypolicies
verbs:
- use
- apiGroups:
- ""
resources:
- persistentvolumeclaims
verbs:
- get
- list
- update
- watch
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- list
- patch
- update
- watch
- apiGroups:
- snapshot.storage.k8s.io
resources:
- volumesnapshots
verbs:
- get
- list
- apiGroups:
- snapshot.storage.k8s.io
resources:
- volumesnapshotcontents
verbs:
- get
- list
- apiGroups:
- storage.k8s.io
resources:
- csinodes
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- storage.k8s.io
resources:
- volumeattachments
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- endpoints
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- apiextensions.k8s.io
- directpv.min.io
resources:
- customresourcedefinitions
- customresourcedefinition
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- directpv.min.io
resources:
- directpvdrives
- directpvvolumes
- directpvnodes
- directpvinitrequests
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
- pods
- pod
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- secrets
- secret
verbs:
- get
- list
- watch


24 changes: 24 additions & 0 deletions resources/base/ClusterRoleBinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
directpv.min.io/plugin-version: v4.1.4
rbac.authorization.kubernetes.io/autoupdate: "true"
creationTimestamp: null
labels:
application-name: directpv.min.io
application-type: CSIDriver
directpv.min.io/created-by: kubectl-directpv
directpv.min.io/version: v1beta1
name: directpv-min-io
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: directpv-min-io
subjects:
- kind: ServiceAccount
name: directpv-min-io
namespace: directpv


Loading

0 comments on commit 1c89522

Please sign in to comment.