kubernetes-cli provides the kubectl command-line tool that allows users to interact with Kubernetes clusters. Kubectl enables developers and administrators to manage containerized applications, deploy services, and monitor cluster resources directly from the command line.
https://formulae.brew.sh/formula/kubernetes-cli
* '''kubectl Executable''': The main command-line tool used to interact with Kubernetes clusters. * '''Configuration Files''': Typically stored in `~/.kube/config`, these files contain information about cluster endpoints, authentication methods, and context settings.
* '''Resource Management''': Create, update, delete, and get information about resources in the cluster. * '''Namespace Support''': Manage resources within specific namespaces for better organization and isolation. * '''Label and Selector Queries''': Use labels and selectors to filter and manage resources. * '''Rolling Updates and Rollbacks''': Perform rolling updates and rollbacks for deployments. * '''Logs and Debugging''': Retrieve logs, describe resources, and troubleshoot issues in the cluster. * '''Extensions''': Supports custom plugins and extensions to enhance functionality.
```bash kubectl config set-cluster my-cluster --server=https://my-cluster.example.com --certificate-authority=ca.crt kubectl config set-credentials my-user --client-certificate=admin.crt --client-key=admin.key kubectl config set-context my-context --cluster=my-cluster --namespace=default --user=my-user kubectl config use-context my-context ```
```bash kubectl apply -f deployment.yaml ```
```bash kubectl get pods -n my-namespace ```
```bash kubectl describe pod my-pod ```
```bash kubectl logs my-pod ```
```bash kubectl exec -it my-pod -- /bin/bash ```
```bash kubectl scale deployment my-deployment --replicas=3 ```
```bash kubectl set image deployment/my-deployment my-container=my-image:v2 ```