当前位置: 首页 > 软件库 > 云计算 > 云原生 >

Kubernetes-Certified-Administrator

授权协议 CC-BY-SA-4.0 License
开发语言 Google Go
所属分类 云计算、 云原生
软件类型 开源软件
地区 不详
投 递 者 林项明
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

License: CC BY-SA 4.0

Kubernetes Certified Administration

Online resources that will help you prepare for taking the Kubernetes Certified Administrator Certification exam.

Disclaimer: This is not likely a comprehensive list as the exam will be a moving target with the fast pace of k8s development - please make a pull request if there something wrong, should be added, or updated.

I tried to restrict the cross references of resources to kubernetes.io. Youtube videos and other blog resources are optional; however, I still found them useful in my k8s learning journey.

Ensure you have the right version of Kubernetes documentation selected (e.g. v1.21 as of June 2021 exam) especially for API objects and annotations.

LDR: practice practice practice

Other CK exams:

CKA 2021 Exam Objectives

These are the exam objectives you review and understand in order to pass the test.

Cluster Architecture, Installation, and Configuration 25%

  1. Manage role based access control

  2. Use kubeadm to install a basic cluster

  3. Manage a highly available Kubernetes cluster

  4. Provision underlying infrastructure to deploy Kubernetes cluster

  5. Peform a version upgrade on Kubernetes cluster using kubeadm

  6. implment etcd backup and restore

    Kubecon Europe 2020: Kubeadm deep dive

sample commands used during backup/restore/update of nodes

#etcd backup and restore brief
export ETCDCTL_API=3  # needed to specify etcd api versions, not sure if it is needed anylonger with k8s 1.19+ 
etcdctl snapshot save -h   #find save options
etcdctl snapshot restore -h  #find restore options

## possible example of save, options will change depending on cluster context, as TLS is used need to give ca,crt, and key paths
etcdctl snapshot save /backup/snapshot.db  --cert=/etc/kubernetes/pki/etcd/server.crt  --key=/etc/kubernetes/pki/etcd/server.key --      cacert=/etc/kubernetes/pki/etcd/ca.crt


# evicting pods/nodes and bringing back node back to cluster
kubectl drain  <node># to drain a node
kubectl uncordon  <node> # to return a node after updates back to the cluster from unscheduled state to Ready
kubectl cordon  <node>   # to not schedule new pods on a node

#backup/restore the cluster (e.g. the state of the cluster in etcd)


# upgrade kubernetes worker node
kubectl drain <node>
apt-get upgrade -y kubeadm=<k8s-version-to-upgrade>
apt-get upgrade -y kubelet=<k8s-version-to-upgrade>
kubeadm upgrade node config --kubelet-version <k8s-version-to-upgrade>
systemctl restart kubelet
kubectl uncordon <node>


#kubeadm upgrade steps
kubeadm upgrade plan
kubeadm upgrade apply

Workloads & Scheduling – 15%

  1. Understand deployments and how to perform rolling update and rollbacks
  2. Use ConfigMaps and Secrets to configure applications
  1. Know how to scale applications
  1. Understand the primitives used to create robust, self-healing, application deployments
  1. Understand how resource limits can affect Pod scheduling
  2. Awareness of manifest management and common templating tools

Services & Networking – 20%

  1. Understand host networking configuration on the cluster nodes

  2. Understand connectivity between Pods

  3. Understand ClusterIP, NodePort, LoadBalancer service types and endpoints

  4. Know how to use Ingress controllers and Ingress resources

    • Ingress concepts
  5. Know how to configure and use CoreDNS

  6. Choose an appropriate container network interface plugin

Storage – 10%

  1. Understand storage classes, persistent volumes
  2. Understand volume mode, access modes and reclaim policies for volumes
  3. Understand persistent volume claims primitive
  4. Know how to configure applications with persistent storage
StorageClass, PersistentVolume, and PersitentVolumeClaim examples

#### Storage Class example
#

#### Persistent Volume Claim example
#
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: local-pvc
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: local-storage-sc
  resources:
    requests:
      storage: 100Mi

## Persistent Volume example
#
apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-pv
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 200Mi
  local:
    path: /data/pv/disk021
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage-sc
  volumeMode: Filesystem

###  Pod using the pvc
#
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
      - name: local-persistent-storage
        mountPath: /var/www/html
  volumes:
    - name: local-persistent-storage
      persistentVolumeClaim:
        claimName: local-pvc

Troubleshooting – 30%

  1. Evaluate cluster and node logging
  2. Understand how to monitor applications
  3. Manage container stdout & stderr logs
  4. Troubleshoot application failure
  5. Troubleshoot cluster component failure
  6. Troubleshoot networking

Tips:

practice practice practice

Get familiar with:

     $kubectl get pods -o wide  --show-labels  --all-namespaces
     or
     $kubectl get pods -o wide  --show-labels  -A     # -A is quicker than --all-namespaces
  • In kubectl utilizie --all-namespaces or better -A to ensure deployments, pods, objects are on the right name space, and right desired state

  • for events and troubleshooting utilize kubectl describe if its pod/resource related and logs if it is application issue related

     $kubectl describe pods <PODID>   # for pod, deployment, other k8s resource issues/events
     $kubectl logs <PODID>            # for container/application issues like crash loops
     
  • fast with kubectl e.g. the '-o yaml' in conjuction with --dry-run=client allows you to create a manifest template from an imperative spec, combined with --edit it allows you to modify the object before creation
kubectl create service clusterip my-svc -o yaml --dry-run=client > /tmp/srv.yaml
kubectl create --edit -f /tmp/srv.yaml
  • use kubectl aliases to speed up and reduce typo errors, practice these alaises early at your work and study for the exam. some example aliases:
alias k='kubectl'
alias kg='kubectl get'
alias kgpo='kubectl get pod'
alias kcpyd='kubectl create pod -o yaml --dry-run=client'
alias ksysgpo='kubectl --namespace=kube-system get pod'

alias kd='kubectl delete'
alias kdf='kubectl delete -f'
## for quick deletes you can add --force --grace-period=0  **Not sure if it is a good idea if you are in a production cluster**
alias krmgf='kubectl delete --grace-period 0 --force'
alias kgsvcoyaml='kubectl get service -o=yaml'
alias kgsvcwn='watch kubectl get service --namespace'
alias kgsvcslwn='watch kubectl get service --show-labels --namespace'

#example usage of aliases
krmgf nginx-8jk71    # kill pod nginx-8jk71 using grace period 0 and force

  • Enable kubectl autocomplete. Autocomplete is the life saviour in any timebound exam as well as our day to day work (e.g. If autocomplete enabled k -n [Press Tab] will suggest available namespaces). Example command to enable autocomplete is available at official kubectl Cheat Sheet page, you don't have to remember anything.
source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.

alias k=kubectl
complete -F __start_kubectl k

Miscellaneous (resources not allowed during exam):

  1. Troubleshooting use cases by Ian/Container solutions

Popular training and practice sites:

Double check if the course is uptodate with the latest exam information (e.g. api, or curicuilim)

Quick review material

What's Next:

  • 1.kubectl api-versions查看kubectl的用户组。cat .kube/config查看配置信息,client-certificate-data可以看到用户的认证信息,client-key-data用户的密钥信息。 [root@master ~]# kubectl api-versions admissionregistration.k8s.io/v1beta1 apiexte

  • Service Account Service Account概念的引入是基于这样的使用场景:运行在pod里的进程需要调用Kubernetes API以及非Kubernetes API的其它服务。Service Account它并不是给kubernetes集群的用户使用的,而是给pod里面的进程使用的,它为pod提供必要的身份认证。 kubectl get sa --all-namespaces

  • 认证安全 任何用途操作集群的资源对象是,都要经历三种安全相关的操作: 任何用户来访问时, 都需要完成kubernetes系统认证操作 认证通过后, 进行授权检查 准入控制, 检查是否有权限操作其它的一些资源操作 认证方式: 令牌认证 SSL 秘钥认证, 也是最常用的方式. RBAC 全程:Role Base AccessControl 授权检查机制 客户端 --> API Server 传递的参数

  • kubernetes的Service Account Service account作用 Service account是为了方便Pod里面的进程调用Kubernetes API或其他外部服务。 Service account使用场景 运行在pod里的进程需要调用Kubernetes API以及非Kubernetes API的其它服务。Service Account它并不是给kubernetes集

  • ServiceAccount 每个namespace下有一个名为default的默认的ServiceAccount对象,这个ServiceAccount里有一个名为Tokens的可以作为Volume一样被Mount到Pod里的Secret,当Pod启动时这个Secret会被自动Mount到Pod的指定目录下,用来协助完成Pod中的进程访问API Server时的身份鉴权过程。 如果一个Pod在定义

  • 背景:最近客户需要回收root权限,需要自己创建audio用户并设置为sudo权限 问题:项目都是用k8s部署的,创建了audio用户并设置了sudo权限之后,切换到audio用户下执行 kubectl get po报错: error: Error loading config file "/etc/kubernetes/admin.conf": open /etc/kubernetes/admi

  • Kubernetes Names Kubernetes REST API中的所有对象都用Name和UID来明确地标识。 对于非唯一用户提供的属性,Kubernetes提供labels和annotations。 Name Name在一个对象中同一时间只能拥有单个Name,如果对象被删除,也可以使用相同Name创建新的对象,Name用于在资源引用URL中的对象,例如/api/v1/pods/some-

 相关资料
  • Kubernetes (通常称为 K8s) 是来自 Google 云平台的开源容器集群管理系统,用于自动部署、扩展和管理容器化(containerized)应用程序。该系统基于 Docker 构建一个容器的调度服务。 Kubernetes 可以自动在一个容器集群中选择一个工作容器供使用。其核心概念是 Container Pod。详细的设计思路请参考这里。 Kubernetes 由 Google 设

  • 我正在使用Ansible、Docker、Jenkins和Kubernetes实现持续集成和持续部署。我已经使用Ansible和kubespray部署创建了一个具有1个主节点和2个工作节点的Kubernetes集群。我有30-40个微服务应用。我需要创建这么多的服务和部署。 我的困惑 当我使用Kubernetes包管理器Kubernetes Helm chart时,我需要在主节点上启动我的图表,还是

  • 扩展应用 通过修改Deployment中副本的数量(replicas),可以动态扩展或收缩应用: 这些自动扩展的容器会自动加入到service中,而收缩回收的容器也会自动从service中删除。 $ kubectl scale --replicas=3 deployment/nginx-app $ kubectl get deploy NAME DESIRED CURRENT

  • 体验Kubernetes最简单的方法是跑一个nginx容器,然后使用kubectl操作该容器。Kubernetes提供了一个类似于docker run的命令kubectl run,可以方便的创建一个容器(实际上创建的是一个由deployment来管理的Pod): $ kubectl run --image=nginx:alpine nginx-app --port=80

  • 我试图在Kubernetes上运行Spark作为调度程序。 当使用从kubernetes集群外部运行时,它可以正常工作。 但是,每当我们尝试从pod中直接运行spark-shell或spark-submit时,它都不会起作用(即使使用从spark文档中执行rbac也不会起作用。我们有授权执行异常: io.fabric8.kubernetes.client.kubernetesclientExcep

  • 部署单元 依赖方式 架构模式 微服务涉及的技术点 服务发现 服务目录 服务列表 配置中心 服务生命周期 变更,升级 服务依赖关系 链路跟踪 限流 降级 熔断 访问控制 为微服务而生的 Kubernetes Kubernetes 架构 Kubernetes Pod - Sidecar 模式 Kubernetes 支持微服务的一些特性 微服务集大成之 istio Kubernetes 架构 一个状态存