AppSec & Pentest
CloudSec
CloudSec
  • Sandboxes, Containers, Virtualization
    • Какие бывают
    • Kubernetes
      • About
      • Tools
        • kubectl
        • minikube
        • helm
        • tiller
        • Others
      • Components
      • Concepts
      • Security
      • Learning
      • Conferences & Events
    • Container Runtime Interface (CRI)
      • containerd
      • CRI-0
      • Podman
      • Colima
      • Docker
        • About
        • CLI
        • Dockerfile
        • docker compose
        • Registry
        • Testcontainers
        • [Def] Security
        • [Off] Security
    • Red Hat OpenShift Container Platform (OCP)
      • About
      • OCP Components
        • Platform services
        • Application services
        • Developer services
        • OpenShift Kubernetes Engine
      • Security
        • Container Security
        • Podman
        • Kubernetes Security
        • Securing Platform Services
        • Vulnerabilities
        • CIS
    • VMWare
      • Workspace ONE Access
      • Workspace One UEM SSRF (AirWatch)
      • vSphere
      • vCenter
      • Learn
      • Horizon Security Server
      • VMWare log4j
    • Tools
      • Build container image inside containers
      • Moby
      • Security
  • Cloud
    • Google Cloud Platform (GCP)
      • GCP Components
      • GCP CLI
      • Security
        • Get access to GCP via service-account [json]
        • PrivEsc
        • Papers
      • Courses & Certifications
    • Azure
      • Azure Start
      • Azure CLI
      • Компоненты и механизмы
        • Azure Storage BLOB
        • Подписанные URL (SAS)
      • Papers and Resources
      • Azure Security Center
      • Tools
    • AWS
      • AWS Intro
      • AWS Basics
      • AWS Components
        • Computing
        • Storage
        • Messaging
        • Serverless
        • Business Productivity
        • Network and Content Delivery
        • Mobile
        • Databases
      • AWS Testing
      • Basic Work: Examples
        • AWS Cli
        • AWS SES
        • S3 Bucket
      • Security
        • Enumeration
        • AWS Lambda
        • Разные примеры
        • Learn Materials
      • Books & Papers
      • Courses & Certifications
    • Yandex Cloud
      • YC CLI
      • YC API
      • Cloud Organization
      • VM
        • Cloud Computing
        • Virtual Private Cloud (VPC)
        • Network Load Balancer
      • Data Platform
        • Definitions
        • Как выбрать БД
        • Реляционные БД
        • Нереляционные БД
        • Object Storage and S3
      • Yandex k8s
      • Serverless
      • Security
      • Billing
    • Another platforms
    • OpenStack
    • Tools
      • Tool list
      • Packer
      • Terraform
        • Intro
        • Getting started
        • Configuration
          • Basic
            • Terraform Block
            • Providers
            • Resources
            • Variables
            • Outputs
            • Functions
          • Modules
        • Security
        • Papers
    • Papers
Powered by GitBook
On this page
  • Подключение к кластеру по токену
  • Примеры использования kubectl
  • Troubleshooting
  • Что еще можем получить
  • Плагины
  • rakkess / access-matrix
  • kubectl-who-can
  • rbac-lookup

Was this helpful?

  1. Sandboxes, Containers, Virtualization
  2. Kubernetes
  3. Tools

kubectl

Подключение к кластеру по токену

Секрет и цепочку сертификатов можно найти на ControlPanel ноде (по умолчанию, порт 22623) https://<Address Node>:22623/config/master или /config/worker

Там будет конфиг kubeconfig:

clusters:
- cluster:
    certificate-authority-data: LS0t...
  name: someName
contexts:
- context:
    cluster: someName
    user: userSecret
  name: contextName
current-context: contextName
preferences: {}
users:
- name: userSecret
  user:
    token: eyJhbGc...

certificate-authority-data мы декодируем из base64 (там будет цепочка PEM сертификатов) и записываем в файл cert.crt. Далее, настраиваем контекст в kubectl:

kubectl config set-credentials "userSecret" --token="<JWT>"
kubectl config set-cluster clusterName --server="https://<Address Node>:6443" --certificate-authority="/path/to/chain/cert.crt"  --embed-certs
kubectl config set-context contextName --cluster="clusterName" --user="usereSecret"
kubectl config use-context contextName
kubectl get pods

Примеры использования kubectl

Получаем список пространств kubectl get namespaces kubectl get ns Создать пространство: kubectl create ns <name> Удалить пространство: kubectl delete namespaces <name>

Работа с подами Получить информацию о поде: kubectl describe pod re-privategallery-backend-978dddf6-d2wgx Все поды: kubectl get pods

Текущий контекст: kubectl config current-context Переключить в контексте на другой namespace: kubectl config set-context <CONTEXT, ex: minikube> --namespace <NAMESPACE>

Посмотреть Persistance Volume: kubectl get pv Посмотреть Persistance Volume Claim: kubectl get pvc

Troubleshooting

Что еще можем получить

Запуск без проверки сертификата:

$ kubectl --insecure-skip-tls-verify <cmd>

Доступные ресурсы (= информация о k8s-ноде)

kubectl --insecure-skip-tls-verify api-resources

Можно получить HTTP запрос, соотв команде kubectl:

$ kubectl --insecure-skip-tls-verify auth can-i list pods -v 9
I0112 16:04:38.235938   37941 round_trippers.go:435] curl -k -v -XGET  -H "Accept: application/json, */*" -H "Authorization: Bearer <masked>" -H "User-Agent: kubectl/v1.21.5 (darwin/amd64) kubernetes/aea7bba" 'https://<IP>:6443/api/v1?timeout=32s'
...
I0112 16:04:38.270815   37941 round_trippers.go:435] curl -k -v -XPOST  -H "Accept: application/json, */*" -H "Content-Type: application/json" -H "User-Agent: kubectl/v1.21.5 (darwin/amd64) kubernetes/aea7bba" -H "Authorization: Bearer <masked>" 'https://<IP>:6443/apis/authorization.k8s.io/v1/selfsubjectaccessreviews'

Плагины

Полезные плагины:

rakkess / access-matrix

Позволяет посмотреть все полномочия, которые были предоставлены пользователю

$ kubectl krew install access-matrix 
$ kubectl access-matrix -n my-project-dev --as jean

kubectl-who-can

rbac-lookup

PreviousToolsNextminikube

Last updated 2 years ago

Was this helpful?

У kubectl есть система плагинов. Есть плагин Krew, который упрощает установку других плагинов. Как поставить Krew

позволяет нам узнать, какие пользователи могут выполнить определенное действие. Он помогает ответить на вопрос: «Кто может это сделать?».

предоставляет обзор RBAC-правил. Он помогает ответить на вопросы: «В какую роль входят jean и sarah?», «В какую роль входят все пользователи?», «В какую роль входит вся группа?».

https://managedkube.com/kubernetes/k8sbot/troubleshooting/imagepullbackoff/2019/02/23/imagepullbackoff.html
https://krew.sigs.k8s.io/docs/user-guide/quickstart/
Этот проект
Этот проект