Skip to content

Commit

Permalink
Updated resources for v4.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveenrajmani committed Sep 25, 2024
1 parent 1c89522 commit 79f0c87
Show file tree
Hide file tree
Showing 61 changed files with 149 additions and 2,698 deletions.
46 changes: 11 additions & 35 deletions generate-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,48 +71,24 @@ function git_commit() {
}

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='~~~'
"${KUBECTL_DIRECTPV}" install -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
name=$(awk '/^kind:/ { print $NF }' "${file}")
if [ "${name}" == "CustomResourceDefinition" ]; then
name=$(awk '/^ name:/ { print $NF }' "${file}")
fi
if [ -n "${name}" ]; then
mv "${file}" "${PWD}/resources/base/resources/${name}.yaml"
else
rm "${file}"
fi
done

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

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

init "$@"
Expand Down
4 changes: 2 additions & 2 deletions pkg/admin/installer/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (t daemonsetTask) doCreateDaemonset(ctx context.Context, args *Args) (err e
}
}
if selectorValue == "" {
selectorValue = fmt.Sprintf("%v-%v", consts.Identity, getRandSuffix())
selectorValue = fmt.Sprintf("%v-%v", consts.Identity, consts.NodeServerName)
}

daemonset := newDaemonset(podSpec, consts.NodeServerName, selectorValue, args)
Expand Down Expand Up @@ -360,7 +360,7 @@ func (t daemonsetTask) doCreateLegacyDaemonset(ctx context.Context, args *Args)
}
}
if selectorValue == "" {
selectorValue = fmt.Sprintf("%v-%v", consts.Identity, getRandSuffix())
selectorValue = fmt.Sprintf("%v-%v", consts.Identity, consts.LegacyNodeServerName)
}

daemonset := newDaemonset(podSpec, consts.LegacyNodeServerName, selectorValue, args)
Expand Down
2 changes: 1 addition & 1 deletion pkg/admin/installer/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (t deploymentTask) doCreateDeployment(ctx context.Context, args *Args, lega
}
}
if selectorValue == "" {
selectorValue = fmt.Sprintf("%v-%v", consts.ControllerServerName, getRandSuffix())
selectorValue = fmt.Sprintf("%v-%v", consts.ControllerServerName, name)
}

replicas := int32(3)
Expand Down
11 changes: 0 additions & 11 deletions pkg/admin/installer/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ package installer

import (
"context"
"crypto/rand"
"encoding/base32"
"path"
"strings"

"github.com/minio/directpv/pkg/k8s"
"k8s.io/klog/v2"
Expand All @@ -31,14 +28,6 @@ func newPluginsSocketDir(kubeletDir, name string) string {
return path.Join(kubeletDir, "plugins", k8s.SanitizeResourceName(name))
}

func getRandSuffix() string {
b := make([]byte, 5)
if _, err := rand.Read(b); err != nil {
klog.Fatalf("unable to generate random bytes; %v", err)
}
return strings.ToLower(base32.StdEncoding.EncodeToString(b)[:5])
}

func sendDoneMessage(ctx context.Context, progressCh chan<- Message, err error) (sent bool) {
sent = sendMessage(ctx, progressCh, newDoneMessage(err))
if !sent && err != nil {
Expand Down
21 changes: 21 additions & 0 deletions resources/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: directpv
commonAnnotations:
directpv.min.io/authors: MinIO, Inc.
directpv.min.io/support: https://subnet.min.io
resources:
- resources/Namespace.yaml
- resources/directpvdrives.directpv.min.io.yaml
- resources/directpvinitrequests.directpv.min.io.yaml
- resources/directpvnodes.directpv.min.io.yaml
- resources/directpvvolumes.directpv.min.io.yaml
- resources/CSIDriver.yaml
- resources/StorageClass.yaml
- resources/ServiceAccount.yaml
- resources/ClusterRole.yaml
- resources/ClusterRoleBinding.yaml
- resources/Role.yaml
- resources/RoleBinding.yaml
- resources/DaemonSet.yaml
- resources/Deployment.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ metadata:
spec:
selector:
matchLabels:
selector.directpv.min.io: directpv-min-io-2c3pu
selector.directpv.min.io: directpv-min-io-4te5s
template:
metadata:
annotations:
created-by: kubectl-directpv
creationTimestamp: null
labels:
selector.directpv.min.io: directpv-min-io-2c3pu
selector.directpv.min.io: directpv-min-io-4te5s
selector.directpv.min.io.service: enabled
name: node-server
namespace: directpv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
replicas: 3
selector:
matchLabels:
selector.directpv.min.io: controller-ms345
selector.directpv.min.io: controller-ttvb4
strategy:
type: Recreate
template:
Expand All @@ -26,7 +26,7 @@ spec:
created-by: kubectl-directpv
creationTimestamp: null
labels:
selector.directpv.min.io: controller-ms345
selector.directpv.min.io: controller-ttvb4
name: controller
namespace: directpv
spec:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions resources/kustomization.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions resources/legacy/base/CSIDriver.yaml

This file was deleted.

173 changes: 0 additions & 173 deletions resources/legacy/base/ClusterRole.yaml

This file was deleted.

Loading

0 comments on commit 79f0c87

Please sign in to comment.