Basic commands
Commands that admins use most often to look into a cluster. Run them in the Hosty container (make cli), with an MFA session (hosty auth) and the VPN of the cluster connected.
Names to know:
What | Name |
|---|---|
Namespaces of a project | <project>-production and <project>-development |
Helm release of an environment | <project>-<environment>, for example shop-production or shop-stage |
Pods of an application | <project>-<environment>-<application>-... |
Containers in a pod | php with nginx or apache, node, or python with nginx |
Connect to a cluster
aws eks update-kubeconfig --name <cluster> --region <region>It adds the cluster to your kubectl config and makes it the current one. Hosty CLI does the same for you on the first command for a project. With several clusters, switch between them with:
kubectl config get-contexts
kubectl config use-context <context>Environments
List all environments of all projects:
helm ls -AList the environments of a project, including the ones that failed or got stuck:
helm ls --all -n <project>-developmentSee the last deployments of an environment and the version of Hosty that made them:
helm history -n <project>-production <project>-productionDelete a development environment, the same as hosty delete <environment>:
helm uninstall -n <project>-development <project>-<environment>Only admins can delete production, which makes a final backup and then drops its database. See Deleting a project.
Pods
List the namespaces, and the pods of a namespace:
kubectl get namespaces
kubectl get pods -n <namespace>List the pods of one environment:
kubectl get pods -n <namespace> -l app.kubernetes.io/part-of=<project>-<environment>Show recent events of a namespace, such as failed scheduling, failed image pulls or failed health checks:
kubectl get events -n <namespace> --sort-by=.lastTimestampList the jobs and cron jobs of a namespace (imports, backups, cleanups, hosty run, cron):
kubectl get jobs,cronjobs -n <namespace>Open a shell in a container:
kubectl exec -it -n <namespace> <pod> -c <container> -- shLogs
Logs of all containers in a pod, or of one container:
kubectl logs -n <namespace> <pod> --all-containers
kubectl logs -n <namespace> <pod> -c <container>Add --previous to see the logs of a container before it restarted, and -f to follow them.
Logs of pods that no longer exist are in CloudWatch, see Observability.
Resources
CPU and memory used by the nodes, with the group of each node:
kubectl top nodes
kubectl get nodes -L groupNameCPU and memory used by the pods of a namespace, or by each container:
kubectl top pods -n <namespace>
kubectl top pods -n <namespace> --containersThe autoscaling of production, with its current and target use:
kubectl get hpa -n <project>-production