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

cephfs: use userid and keys for provisioning #4988

Merged
merged 4 commits into from
Jan 8, 2025
Merged
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
6 changes: 2 additions & 4 deletions charts/ceph-csi-cephfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,8 @@ charts and their default values.
| `storageClass.mountOptions` | Specifies the mount options | `[]` |
| `secret.create` | Specifies whether the secret should be created | `false` |
| `secret.name` | Specifies the cephFS secret name | `csi-cephfs-secret` |
| `secret.adminID` | Specifies the admin ID of the cephFS secret | `<plaintext ID>` |
| `secret.adminKey` | Specifies the key that corresponds to the adminID | `""` |
| `secret.userID` | Specifies the user ID of the cephFS secret. Optional, used for static provisioned PVC. | `""` |
| `secret.userKey` | Specifies the key that corresponds to the userID. Optional, used for static provisioned PVC. | `<Ceph auth key corresponding to ID above>` |
| `secret.userID` | Specifies the user ID of the cephFS secret. | `""` |
| `secret.userKey` | Specifies the key that corresponds to the userID. | `<Ceph auth key corresponding to ID above>` |
| `selinuxMount` | Mount the host /etc/selinux inside pods to support selinux-enabled filesystems | `true` |
| `CSIDriver.fsGroupPolicy` | Specifies the fsGroupPolicy for the CSI driver object | `File` |
| `CSIDriver.seLinuxMount` | Specify for efficient SELinux volume relabeling | `true` |
Expand Down
6 changes: 0 additions & 6 deletions charts/ceph-csi-cephfs/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ metadata:
heritage: {{ .Release.Service }}
{{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
stringData:
{{- if .Values.secret.userID }}
userID: {{ .Values.secret.userID }}
{{- end }}
{{- if .Values.secret.userKey }}
userKey: {{ .Values.secret.userKey }}
{{- end }}
adminID: {{ .Values.secret.adminID }}
adminKey: {{ .Values.secret.adminKey }}
{{- end -}}
7 changes: 2 additions & 5 deletions charts/ceph-csi-cephfs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,8 @@ secret:
# Key values correspond to a user name and its key, as defined in the
# ceph cluster. User ID should have required access to the 'pool'
# specified in the storage class
adminID: <plaintext ID>
adminKey: <Ceph auth key corresponding to ID above>
# User credentials are required for the static provisioned PVC.
userID: ""
userKey: ""
userID: <plaintext ID>
userKey: <Ceph auth key corresponding to the userID above>

# This is a sample configmap that helps define a Ceph configuration as required
# by the CSI plugins.
Expand Down
6 changes: 0 additions & 6 deletions docs/cephfs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ to use the output of `ceph fsid` of the Ceph cluster to be used for
provisioning.

**Required secrets for provisioning:**
Admin credentials are required for provisioning new volumes

* `adminID`: ID of an admin client
* `adminKey`: key of the admin client

**Required secrets for statically provisioned volumes:**
User credentials with access to an existing volume

* `userID`: ID of a user client
Expand Down
3 changes: 3 additions & 0 deletions e2e/cephfs_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func createCephfsSecret(f *framework.Framework, secretName, userName, userKey st
if secretName != "" {
sc.Name = secretName
}
// TODO: Update the secrets to use userID and userKey once
Madhu-1 marked this conversation as resolved.
Show resolved Hide resolved
// the version used for upgrade testing does not depend on
// adminID and adminKey.
Madhu-1 marked this conversation as resolved.
Show resolved Hide resolved
sc.StringData["adminID"] = userName
sc.StringData["adminKey"] = userKey
delete(sc.StringData, "userID")
Expand Down
6 changes: 1 addition & 5 deletions examples/cephfs/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ metadata:
name: csi-cephfs-secret
namespace: default
stringData:
# Required for statically provisioned volumes
# Required for statically and dynamically provisioned volumes
userID: <plaintext ID>
userKey: <Ceph auth key corresponding to ID above>

# Required for dynamically provisioned volumes
adminID: <plaintext ID>
adminKey: <Ceph auth key corresponding to ID above>

# Encryption passphrase
encryptionPassphrase: test_passphrase
8 changes: 8 additions & 0 deletions internal/util/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"errors"
"fmt"
"os"

"github.com/ceph/ceph-csi/internal/util/log"
)

const (
Expand Down Expand Up @@ -110,6 +112,12 @@ func NewUserCredentials(secrets map[string]string) (*Credentials, error) {

// NewAdminCredentials creates new admin credentials from secret.
func NewAdminCredentials(secrets map[string]string) (*Credentials, error) {
// Use userID and userKey if found else fallback to adminID and adminKey
if cred, err := newCredentialsFromSecret(credUserID, credUserKey, secrets); err == nil {
return cred, nil
}
log.WarningLogMsg("adminID and adminKey are deprecated, please use userID and userKey instead")

return newCredentialsFromSecret(credAdminID, credAdminKey, secrets)
}

Expand Down
8 changes: 3 additions & 5 deletions scripts/install-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ install_cephcsi_helm_charts() {
if [ "${DEPLOY_SECRET}" -eq 1 ]; then
fetch_template_values
RBD_SECRET_TEMPLATE_VALUES="--set secret.create=true --set secret.userID=admin --set secret.userKey=${ADMIN_KEY}"
CEPHFS_SECRET_TEMPLATE_VALUES="--set secret.create=true --set secret.adminID=admin --set secret.adminKey=${ADMIN_KEY}"
CEPHFS_SECRET_TEMPLATE_VALUES="--set secret.create=true --set secret.userID=admin --set secret.userKey=${ADMIN_KEY}"
fi
# enable read affinity
if [ "${ENABLE_READ_AFFINITY}" -eq 1 ]; then
Expand Down Expand Up @@ -232,16 +232,14 @@ if ! helm_loc="$(type -p "helm")" || [[ -z ${helm_loc} ]]; then
HELM="${TEMP}/${dist}-${arch}/helm"
fi

if [ "$#" -le 2 ]
then
if [ "$#" -le 2 ]; then
ACTION=$1
NAMESPACE=$2
SKIP_PARSE="true"
fi

if [ ${#SKIP_PARSE} -eq 0 ]; then
while [ "$1" != "" ]
do
while [ "$1" != "" ]; do
case $1 in
up)
shift
Expand Down
Loading