EKS Cluster: Part 9 – Ai Ops/Dev = K8sGPT

Series of blog posts show progress of updating/adding to EKS Cluster, this post covers adding K8sGPT under Ai Operations. See below for past posts:

K8sGPT: feed it unhealthy workloads to analyze K8s events/errors & compare to kubectl describe/logs

  • Good opportunity to intentionally break something and see whether it identifies the root cause
K8s GPT Does 3 things:Key Commands to use will be (once K8sGPT is installed)Priority order of fix may include
Detects a Kubernetes warning or unhealthy state.kgpt-scanFix now:
CrashLoopBackOff, ImagePullBackOff, failed mounts, scheduling failures, unavailable Deployments, failing PVCs.
Sends the technical context to Amazon Bedrock.kgpt-resultsInvestigate:
– Repeated restarts, probe failures, unhealthy Services, resource pressure, recurring failed Jobs.
Stores an AI-generated explanation and suggested remediation in a Result resource.kgpt-showUsually cleanup/no action:
– Completed CronJob Pods, older failed Jobs already replaced by successful runs, deleted resources, or transient startup errors.
kgpt-logs

Folders & files organized as such:

  • Flow order:
    • K8sGPT Bedrock IAM policy
    • K8sGPT IRSA role
    • EKS OIDC trust restricted to
      • ServiceAccount: k8sgpt:k8sgpt-bedrock
    • Permissions include –
      • bedrock:InvokeModel
      • bedrock:InvokeModelWithResponseStream
  • gitops
    • Applications
      • k8sgpt-operator.yaml
      • k8sgpt.yaml
    • Apps
      • k8sgpt-operator
        • values.yaml
      • k8sgpt
        • k8sgpt.yaml
        • serviceaccount.yaml
  • infra
    • k8sgpt-iam.tf
    • k8sgpt-policy.tf

Pre-Commands:

==========================================
- helm repo add k8sgpt https://charts.k8sgpt.ai/
- helm repo update
==========================================
- helm search repo k8sgpt/k8sgpt-operator \
--versions |
head -10
==========================================
- helm show values k8sgpt/k8sgpt-operator --version 0.2.29 |
grep -n -A20 -B5 -E \
'serviceAccount:|podSecurityContext|securityContext|resources:'
==========================================
- helm search repo k8sgpt
==========================================

Applications/k8sgpt-operator.yaml:

Variety of kubectl commands to check status:

==========================================
- kubectl get application k8sgpt-operator -n argocd
==========================================
==========================================
- kubectl explain k8sgpt.spec.ai --recursive
==========================================
==========================================
- kubectl get pods -n k8sgpt-operator-system
==========================================
==========================================
- kubectl get serviceaccount -A | grep -i k8sgpt
==========================================

Apps/k8sgpt-operator/values.yaml:

Apps/k8sgpt/k8sgpt.yaml:

CRDs: to help create infra for AWS IAM ISRA & Policy as well as Bedrock

  • Show all top-level K8sGPT
  • Show complete Ai schmea w/out terminal formatting
  • Search CRD for ServiceAccount & Pod Settings
  • Confirm Bedrock backend name
==========================================
- kubectl get crd k8sgpts.core.k8sgpt.ai -o json |
jq -r '
paths
| select(.[-1] == "serviceAccountIRSA")
| map(tostring)
| join(".")
'
==========================================
- kubectl get crd k8sgpts.core.k8sgpt.ai -o json |
jq -r '
.spec.versions[]
| select(.name == "v1alpha1")
| .schema.openAPIV3Schema.properties.spec.properties
| keys[]
'
ai
sink
targetNamespace
version
==========================================

infra/k8sgpt.yaml:

Applications/k8sgpt.yaml:

infra/k8sgpt-iam.tf:

infra/k8sgpt-policy.tf:

Leave a comment