Skip to content

Commit

Permalink
feature: merge evict pod command into debug-pdb
Browse files Browse the repository at this point in the history
  • Loading branch information
dhenkel92 committed Dec 7, 2023
1 parent 8b8bcf1 commit 3b19d47
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 131 deletions.
43 changes: 0 additions & 43 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ builds:
- linux
- windows
- darwin
- env:
- CGO_ENABLED=0
main: ./cmd/kubectl-evict/kubectl-evict.go
id: kubectl-evict
binary: kubectl-evict
goarch:
- amd64
- arm
- arm64
goos:
- linux
- windows
- darwin

archives:
- id: kubectl-debug-pdb
builds:
Expand All @@ -58,22 +44,6 @@ archives:
format_overrides:
- goos: windows
format: zip
- id: kubectl-evict
builds:
- kubectl-evict
format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .Binary }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
brews:
- name: kubectl-debug-pdb
ids:
Expand All @@ -87,19 +57,6 @@ brews:
branch: main
pull_request:
enabled: true
- name: kubectl-evict
ids:
- kubectl-evict
folder: Formula
homepage: "https://github.com/dhenkel92/kubectl-debug-pdb"
license: "MIT"
repository:
owner: dhenkel92
name: homebrew-tap
branch: main
pull_request:
enabled: true

checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
66 changes: 12 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<br/>
<p align="center">
<!-- <a href="https://github.com/dhenkel92/ReadME-Generator"> -->
<!-- <img src="images/logo.png" alt="Logo" width="80" height="80"> -->
<!-- </a> -->

<h3 align="center">Kubectl PDB & Eviction plugin</h3>
<h3 align="center">Kubectl debug PDB plugin</h3>

<p align="center">
A kubectl plugin to work with pod disruption budgets.
Expand Down Expand Up @@ -49,15 +45,12 @@ To get a local copy up and running follow these simple example steps.

You can install the tool via Homebrew and the tap repository can be found [here.](https://github.com/dhenkel92/homebrew-tap)
```
brew update
brew install dhenkel92/homebrew-tap/kubectl-debug-pdb
brew install dhenkel92/homebrew-tap/kubectl-evict
brew update && brew install dhenkel92/homebrew-tap/kubectl-debug-pdb
```

In order to get a newer version, just upgrade via Homebrew
```
brew upgrade kubectl-debug-pdb
brew upgrade kubectl-evict
brew update && brew upgrade dhenkel92/homebrew-tap/kubectl-debug-pdb
```

### Other distributions
Expand All @@ -66,19 +59,18 @@ See the [Releases page](https://github.com/dhenkel92/kubectl-debug-pdb/releases)

## Usage

### Kubectl pdb

```
Utility to work with pod disruption budgets
Usage:
pdb [command]
debug-pdb [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
cover Shows which PDBs are a workload.
create Create a new PDB for a given workload.
help Help about any command
pod Utility to evict a pod from a node
pods List pods covered by a given PDB
Flags:
Expand All @@ -92,7 +84,7 @@ Flags:
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
--disable-compression If true, opt-out of response compression for all requests to the server
-h, --help help for pdb
-h, --help help for debug-pdb
--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
Expand All @@ -102,66 +94,32 @@ Flags:
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
Use "pdb [command] --help" for more information about a command.
Use "debug-pdb [command] --help" for more information about a command.
```

List all pods for a given PDB:
```
kubectl pdb pods <pdb_name>
kubectl debug-pdb pods <pdb_name>
```

List all PDBs for all pods of a namespace:
```
kubectl pdb cover -n <namespace> [pod_name]
kubectl debug-pdb cover -n <namespace> [pod_name]
```

Create new PDB:
```
kubectl pdb create <resource_type>/<resource_name> --dry-run -o yaml
```

### Kubectl evict

```
Utility to evict a pod from a node
Usage:
evict pod [flags]
Flags:
--dry-run If true, only print the object that would be sent, without sending it. (default true)
-h, --help help for pod
-o, --output string Output format. One of: json|yaml (default "json")
Global 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 "/Users/daniel.henkel/.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
--disable-compression If true, opt-out of response compression for all requests to the server
--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
kubectl debug-pdb create <resource_type>/<resource_name> --dry-run -o yaml
```

Evict a pod in dry-run mode (Default: true):
```
kubectl evict pod [-n <namespace>] <pod_name>
kubectl debug-pdb pod [-n <namespace>] <pod_name>
```

Trigger real pod eviction:
```
kubectl evict pod [-n <namespace>] <pod_name> --dry-run=false
kubectl debug-pdb pod [-n <namespace>] <pod_name> --dry-run=false
```

## Contributing
Expand Down
1 change: 1 addition & 0 deletions cmd/kubectl-debug-pdb/kubectl-debug-pdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func main() {
rootCmd.AddCommand(cmd.NewCmdPdb(streams, conf))
rootCmd.AddCommand(cmd.NewCmdCreatePDB(streams, conf))
rootCmd.AddCommand(cmd.NewCmdPods(streams, conf))
rootCmd.AddCommand(cmd.NewCmdEvictPod(streams, conf))

if err := rootCmd.Execute(); err != nil {
os.Exit(1)
Expand Down
33 changes: 0 additions & 33 deletions cmd/kubectl-evict/kubectl-evict.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/cmd/evict_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewCmdEvictPod(streams genericclioptions.IOStreams, configFlags *genericcli
o := NewEvictPodOptions(streams, configFlags)

cmd := &cobra.Command{
Use: "pod <pod_name>",
Use: "evict <pod_name>",
Short: "Utility to evict a pod from a node",
RunE: func(cmd *cobra.Command, args []string) error {
if err := o.Complete(cmd, args); err != nil {
Expand Down

0 comments on commit 3b19d47

Please sign in to comment.