README
¶
rename-pvc
rename-pvc
can rename persistentVolumeClaims (PVC) inside kubernetes.
⚠ Be sure to create a backup of your data in the PVC before you use rename-pvc
!
Installation
From source
If you have Go 1.16+, you can directly install by running:
go install github.com/stackitcloud/rename-pvc/cmd/rename-pvc@latest
Based on your go configuration the
go/template
binary can be found in$GOPATH/bin
or$HOME/go/bin
in case$GOPATH
is not set. Make sure to add the respective directory to your$PATH
. For more information see go docs for further information. Rungo env
to view your current configuration.
From the released binaries
Download the desired version for your operating system and processor architecture from the rename-pvc releases page.
Make the file executable and place it in a directory available in your $PATH
.
Usage
To rename a PVC from pvc-name
to new-pvc-name
run the command:
rename-pvc pvc-name new-pvc-name
Example Output:
Rename PVC from 'pvc-name' to 'new-pvc-name' in namespace 'default'? (yes or no) yes
New PVC with name 'new-pvc-name' created
ClaimRef of PV 'pvc-2dc982d6-72a0-4e80-b1a6-126b108d2adf' is updated to new PVC 'new-pvc-name'
New PVC 'new-pvc-name' is bound to PV 'pvc-2dc982d6-72a0-4e80-b1a6-126b108d2adf'
Old PVC 'pvc-name' is deleted
To select the Namespace and Kubernetes cluster you can use the default kubectl
flags and environment variables (like --namespace
, --kubeconfig
or the KUBECONFIG
environment variable).
For all options run --help
.
Flags:
--as string Username to impersonate for the operation. User could be a regular user or a service account in a namespace.
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--as-uid string UID to impersonate for the operation.
--cache-dir string Default cache directory (default "/home/m/.kube/cache")
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
-h, --help help for /tmp/go-build4237287669/b001/exe/main
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
-n, --namespace string If present, the namespace scope for this CLI request
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-s, --server string The address and port of the Kubernetes API server
--tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
-y, --yes Skips conformation if flag is set
How does it work?
rename-pvc
runs the following steps to rename an PVC in your Kubernetes cluster:
- creates the new PVC with the
.spec.volumeName
set to the existing PVC- This new PVC is now in status
Lost
- This new PVC is now in status
- updates the
spec.claimRef
in thePersistentVolume
to the new PVC - Wait until the new PVC gets in status
Bound
- Deletes old PVC
Maintainers
Name | |
---|---|
@dergeberl | maximilian.geberl@stackit.de |
@brumhard | tobias.brumhard@mail.schwarz |
@mganter | manuel_stefan.ganter@stackit.de |
Contribution
If you want to contribute to rename-pvc
please have a look at our contribution guidelines.