### Install Kuboard Beta Version Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-dashboard.md Apply the beta version of Kuboard and its metrics server. Ensure you are on the master node if following the Kubernetes installation guide from kuboard.cn. ```sh kubectl apply -f https://kuboard.cn/install-script/kuboard-beta.yaml kubectl apply -f https://addons.kuboard.cn/metrics-server/0.3.7/metrics-server.yaml ``` -------------------------------- ### Manual Installation Script for Kubernetes Components Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubernetes.md This is the content of the manual installation script for Kubernetes components. It achieves the same result as the quick installation method. ```shell set -e # Install docker apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io # Install nfs-utils apt-get update && apt-get install -y nfs-common # Install kubectl, kubeadm, kubelet curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - cat < /etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF apt-get update apt-get install -y kubelet kubeadm kubectl # Hold the package version apt-mark hold kubelet kubeadm kubectl # Enable and start kubelet service systemctl enable kubelet systemctl start kubelet echo "Install docker/kubelet successfully!" ``` -------------------------------- ### Install Kuboard-Spray Docker Image Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-k8s.md Run this command on a server with Docker installed to deploy Kuboard-Spray. Ensure Docker is installed and has at least 10GB of free disk space. The command maps host directories for data persistence and exposes port 80 for access. ```shell docker run -d \ --privileged \ --restart=unless-stopped \ --name=kuboard-spray \ -p 80:80/tcp \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/kuboard-spray-data:/data \ eipwork/kuboard-spray:latest-amd64 # 如果抓不到这个镜像,可以尝试一下这个备用地址: # swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard-spray:latest-amd64 ``` -------------------------------- ### Quick Installation of Kubernetes Components Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubernetes.md Execute this script on all master and worker nodes to quickly install Docker, nfs-utils, kubectl, kubeadm, and kubelet. ```shell # Execute on master and worker nodes curl -sSL https://kuboard.cn/install-script/v1.16.2/install_kubelet.sh | sh ``` -------------------------------- ### Install Curl and Test Nginx Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/init-config.md Inside the container shell, install the curl utility and then send a GET request to localhost to verify that the index.html file written by the init container is being served. ```bash apt-get update apt-get install curl curl localhost ``` -------------------------------- ### Access Service via Kuboard Proxy (Curl Example) Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-advanced/proxy/index.md Copy and execute this command in your terminal to get a response from the proxied service. Useful for API testing. ```shell curl -k -H "Authorization: Bearer " http://localhost:8080/api/v1/namespaces/example/services/http:web-example:80/proxy/ ``` -------------------------------- ### Start kubectl proxy Source: https://github.com/eip-work/kuboard-press/blob/master/guide/proxy/index.md Execute this command in your terminal to start the kubectl proxy server. Ensure kubectl is configured on your client. ```sh kubectl proxy ``` -------------------------------- ### Install Kuboard Stable Version Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-dashboard.md Apply the stable version of Kuboard and its metrics server. Ensure you are on the master node if following the Kubernetes installation guide from kuboard.cn. ```sh kubectl apply -f https://kuboard.cn/install-script/kuboard.yaml kubectl apply -f https://addons.kuboard.cn/metrics-server/0.3.7/metrics-server.yaml ``` -------------------------------- ### Cron Schedule Examples Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/wl-cronjob/run.md These examples demonstrate different ways to specify a schedule for a CronJob using cron syntax. They include basic minute-based scheduling, hourly scheduling, and using step values for more complex intervals. ```text 0 * * * * @hourly 0 0,2,4,5,6,8,12,14,16,17,20,22 * * * 0 0-23/2 * * * 0 */2 * * * ``` -------------------------------- ### Scale Deployment Example Source: https://context7.com/eip-work/kuboard-press/llms.txt Scales a Kubernetes deployment named 'nginx-deployment' to 3 replicas using the kubectl scale command. ```bash kubectl scale deployment nginx-deployment --replicas=3 ``` -------------------------------- ### Example kubectl Output Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/config/affinity.md This sample output shows how pods are distributed across nodes, illustrating the effect of affinity and anti-affinity configurations. ```text NAME READY STATUS RESTARTS AGE IP NODE redis-cache-1450370735-6dzlj 1/1 Running 0 8m 10.192.4.2 kube-node-3 redis-cache-1450370735-j2j96 1/1 Running 0 8m 10.192.2.2 kube-node-1 redis-cache-1450370735-z73mh 1/1 Running 0 8m 10.192.3.1 kube-node-2 web-server-1287567482-5d4dz 1/1 Running 0 7m 10.192.2.3 kube-node-1 web-server-1287567482-6f7v5 1/1 Running 0 7m 10.192.4.3 kube-node-3 web-server-1287567482-s330j 1/1 Running 0 7m 10.192.3.2 kube-node-2 ``` -------------------------------- ### Start Kuboard v4 with Docker Compose Source: https://github.com/eip-work/kuboard-press/blob/master/v4/install/quickstart.md Execute this command in the directory containing your docker-compose.yaml file to start the Kuboard v4 services in detached mode. ```sh docker compose up -d ``` -------------------------------- ### Install Kubectl on Linux Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubectl.md Installs the kubectl package using yum after the repository has been configured. This command should be run on a Linux client machine. ```bash yum install -y kubectl ``` -------------------------------- ### Example Deployment Annotations Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/obj/annotations.md Shows practical annotations used in a Kubernetes Deployment, including controller-added revision information and Kuboard-specific display and configuration flags. ```yaml metadata: annotations: deployment.kubernetes.io/revision: 7 k8s.eip.work/displayName: busybox k8s.eip.work/ingress: false k8s.eip.work/service: none ``` -------------------------------- ### Start kubectl Proxy Source: https://context7.com/eip-work/kuboard-press/llms.txt Starts the kubectl proxy, which provides a secure way to access Kubernetes services and the API from your local machine. ```bash # Start kubectl proxy kubectl proxy # Starting to serve on 127.0.0.1:8001 ``` -------------------------------- ### Example Node Description Output Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-bg/architecture/nodes.md This is an example of the detailed output you might receive when describing a Kubernetes node. It includes labels, annotations, conditions, capacity, allocatable resources, system information, and a list of non-terminated pods. ```yaml Name: demo-worker-temp-01 Roles: Labels: beta.kubernetes.io/arch=amd64 beta.kubernetes.io/os=linux kubernetes.io/arch=amd64 kubernetes.io/hostname=demo-worker-temp-01 kubernetes.io/os=linux Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock node.alpha.kubernetes.io/ttl: 0 projectcalico.org/IPv4Address: 172.172.216.105/20 projectcalico.org/IPv4IPIPTunnelAddr: 192.168.199.128 volumes.kubernetes.io/controller-managed-attach-detach: true CreationTimestamp: Mon, 30 Sep 2019 06:30:16 +0800 Taints: Unschedulable: false Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- NetworkUnavailable False Wed, 02 Oct 2019 22:37:33 +0800 Wed, 02 Oct 2019 22:37:33 +0800 CalicoIsUp Calico is running on this node MemoryPressure False Sun, 06 Oct 2019 13:44:41 +0800 Mon, 30 Sep 2019 06:30:16 +0800 KubeletHasSufficientMemory kubelet has sufficient memory available DiskPressure False Sun, 06 Oct 2019 13:44:41 +0800 Mon, 30 Sep 2019 06:30:16 +0800 KubeletHasNoDiskPressure kubelet has no disk pressure PIDPressure False Sun, 06 Oct 2019 13:44:41 +0800 Mon, 30 Sep 2019 06:30:16 +0800 KubeletHasSufficientPID kubelet has sufficient PID available Ready True Sun, 06 Oct 2019 13:44:41 +0800 Wed, 02 Oct 2019 22:37:41 +0800 KubeletReady kubelet is posting ready status Addresses: InternalIP: 172.172.216.105 Hostname: demo-worker-temp-01 Capacity: cpu: 2 ephemeral-storage: 41147472Ki hugepages-1Gi: 0 hugepages-2Mi: 0 memory: 7733524Ki pods: 110 Allocatable: cpu: 2 ephemeral-storage: 37921510133 hugepages-1Gi: 0 hugepages-2Mi: 0 memory: 7631124Ki pods: 110 System Info: Machine ID: 20190711105006363114529432776998 System UUID: 841EC123-F92C-4A3A-BEC0-DAADDD625067 Boot ID: 70c08b02-45ed-456f-8deb-b5c0ebeab414 Kernel Version: 3.10.0-957.21.3.el7.x86_64 OS Image: CentOS Linux 7 (Core) Operating System: linux Architecture: amd64 Container Runtime Version: docker://18.9.7 Kubelet Version: v1.16.0 Kube-Proxy Version: v1.16.0 Non-terminated Pods: (21 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE --------- ---- ------------ ---------- --------------- ------------- --- default nginx-deployment-5754944d6c-8lnlx 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h example gateway-example-6f6f45cd6-mhggv 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h example monitor-grafana-ff99b5b6f-sxppz 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h kube-system calico-node-qjfqd 250m (12%) 0 (0%) 0 (0%) 0 (0%) 6d7h kube-system eip-nfs-cluster-storage-6c9c7d46f4-lmxql 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h kube-system kube-proxy-4xz9h 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d15h kube-system monitor-prometheus-node-exporter-t7d24 0 (0%) 0 (0%) 0 (0%) 0 (0%) 2d20h kuboard-blog cloud-busybox-867645c5dd-7l97b 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h kuboard-blog db-wordpress-79d88d66b7-j7kj8 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h kuboard-press svc-busybox-6cc877b848-2kl28 0 (0%) 0 (0%) 0 (0%) 0 (0%) 3d14h kuboard-press web-kuboard-press-6d6f8bdbb8-c4q44 0 (0%) 0 (0%) 0 (0%) 0 (0%) 2d3h nginx-ingress nginx-ingress-hsv26 0 (0%) 0 (0%) 0 (0%) 0 (0%) 6d7h ``` -------------------------------- ### Get StatefulSets and Services by Namespace Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/obj/field.md This command demonstrates selecting multiple resource types (StatefulSets and Services) across all namespaces, filtering by those not in the 'default' namespace. ```sh kubectl get statefulsets,services --all-namespaces --field-selector metadata.namespace!=default ``` -------------------------------- ### Kubectl Context Configuration Example Source: https://github.com/eip-work/kuboard-press/blob/master/install/config-kubectl.md This YAML snippet shows an example of a kubeconfig file defining multiple contexts, each specifying a cluster, namespace, and user. The 'current-context' field indicates the active configuration. ```yaml contexts: - context: cluster: development namespace: frontend user: developer name: dev-frontend - context: cluster: development namespace: ramp user: developer name: dev-ramp-up - context: cluster: development namespace: storage user: developer name: dev-storage - context: cluster: scratch namespace: default user: experimenter name: exp-scratch current-context: dev-frontend kind: Config users: ... ``` -------------------------------- ### Get Kubernetes Resource Lists with kubectl Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-basics/explore.md Use `kubectl get` to list resources like Deployments, Pods, and Nodes. Add `-A` or `--all-namespaces` to see all namespaces, or `-n ` for a specific one. ```bash # kubectl get 资源类型 #获取类型为Deployment的资源列表 kubectl get deployments #获取类型为Pod的资源列表 kubectl get pods #获取类型为Node的资源列表 kubectl get nodes ``` ```bash # 查看所有名称空间的 Deployment kubectl get deployments -A kubectl get deployments --all-namespaces # 查看 kube-system 名称空间的 Deployment kubectl get deployments -n kube-system ``` -------------------------------- ### Describe Kubernetes Resources with kubectl Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-basics/explore.md Use `kubectl describe` to get detailed information about a specific resource, such as a Pod or Deployment. ```bash # kubectl describe 资源类型 资源名称 #查看名称为nginx-XXXXXX的Pod的信息 kubectl describe pod nginx-XXXXXX #查看名称为nginx的Deployment的信息 kubectl describe deployment nginx ``` -------------------------------- ### Verify kubectl Installation Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubectl.md Execute these commands to verify that kubectl is correctly configured and can communicate with the Kubernetes cluster. ```shell kubectl get nodes ``` ```shell kubectl get pods -n kube-system ``` -------------------------------- ### Pod with an Annotation Example Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/obj/annotations.md Demonstrates how to add a simple annotation, `imageregistry`, to a Pod's metadata to store information like an image registry URL. ```yaml apiVersion: v1 kind: Pod metadata: name: annotations-demo annotations: imageregistry: "https://hub.docker.com/" spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 ``` -------------------------------- ### Quick Master Node Initialization (Shell) Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubernetes.md Execute this script on the first master node to quickly initialize it. Ensure APISERVER_NAME and POD_SUBNET are set correctly and the DNS entry is added to /etc/hosts. ```shell # Only execute on the first master node # Replace apiserver.demo with your desired dnsName export APISERVER_NAME=apiserver.demo # The network segment for Kubernetes pods, created by Kubernetes after installation, does not exist in your physical network beforehand export POD_SUBNET=10.100.0.1/16 echo "127.0.0.1 ${APISERVER_NAME}" >> /etc/hosts curl -sSL https://kuboard.cn/install-script/v1.16.2/init_master.sh | sh ``` -------------------------------- ### Manual Master Node Initialization Setup (Shell) Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubernetes.md This script sets up environment variables and the hosts file for manual master node initialization. The actual initialization script (init_master.sh) needs to be executed separately. ```shell # Only execute on the first master node # Replace apiserver.demo with your desired dnsName export APISERVER_NAME=apiserver.demo # The network segment for Kubernetes pods, created by Kubernetes after installation, does not exist in your physical network beforehand export POD_SUBNET=10.100.0.1/16 echo "127.0.0.1 ${APISERVER_NAME}" >> /etc/hosts ``` -------------------------------- ### Create kubectl Configuration File (Windows) Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubectl.md Create a '.kube/config' file in the user's home directory using a text editor. Paste the content from '/etc/kubernetes/admin.conf' into this file and save it. ```text Create file ~/.kube/config ``` -------------------------------- ### Viewing Pod's resolv.conf (IPv4) Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/service/dns.md Executes a command within the 'dns-example' Pod to display the contents of its `/etc/resolv.conf` file, reflecting the custom DNS configuration. This example assumes an IPv4 environment. ```bash kubectl exec -it dns-example -- cat /etc/resolv.conf ``` -------------------------------- ### Kubernetes Readiness Probe Configuration Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-practice/micro-service/design-pattern.md Configure a readiness probe for a container to ensure it only receives traffic when it is ready to serve requests. This example uses an HTTP GET request. ```yaml readinessProbe: httpGet: path: / port: 5000 timeoutSeconds: 1 periodSeconds: 5 ``` -------------------------------- ### Kubernetes HTTPGet Probe Example Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/pod-health.md This Liveness probe uses an HTTP GET request to check the health of an application. It specifies the path, port, and optionally headers for the request. ```yaml livenessProbe: httpGet: path: /health port: 8080 httpHeaders: - name: Custom-Header value: Awesome ``` -------------------------------- ### Get Busyboxplus Container Terminal Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/service/connecting.md Launches an interactive busyboxplus container with curl installed, allowing you to test DNS resolution and network connectivity within the cluster. Press Enter for the command prompt. ```bash kubectl run curl --image=radial/busyboxplus:curl -i --tty ``` -------------------------------- ### Verify Kubectl Installation on Linux Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubectl.md Checks the installed kubectl version to confirm a successful installation on a Linux system. This is a standard verification step. ```bash kubectl version ``` -------------------------------- ### Get Pod Names for a Service Source: https://github.com/eip-work/kuboard-press/blob/master/t/cka/daily/011.md This command retrieves only the names of pods associated with a specific service. It first uses `kubectl get service` to find the service's labels and then `kubectl get pod` with a custom output format to extract pod names. ```bash kubectl get pods "-o=custom-columns=NAME:.metadata.name" ``` -------------------------------- ### Create Deployment with Multiple Labels Source: https://github.com/eip-work/kuboard-press/blob/master/t/cka/daily/011.md This command demonstrates creating a deployment with multiple labels applied. It's a variation of the initial deployment creation, showcasing how to assign several key-value pairs to a Pod. ```bash kubectl run cka-1203-03 --image=nginx --labels="a=a,b=b" deployment.apps/cka-1203-03 created ``` -------------------------------- ### Dockerfile for Building an Executable Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-practice/micro-service/design-pattern.md This Dockerfile example demonstrates a common anti-pattern where build tools and source code are included in the final image, increasing its size and posing security risks. Consider using multi-stage builds to avoid this. ```dockerfile FROM ubuntu:14.04 RUN apt-get update RUN apt-get install gcc RUN gcc hello.c -o /hello ``` -------------------------------- ### Register Pod with Management Service Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/init-container.md This example shows how an init container can register the Pod with a management service using its name and IP address. Ensure the management service host and port are correctly set. ```sh curl -X POST http://$MANAGEMENT_SERVICE_HOST:$MANAGEMENT_SERVICE_PORT/register -d 'instance=$()&ip=$()' ``` -------------------------------- ### Install Rook Ceph Cluster Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/persistent/ceph/rook-config.md Execute these commands sequentially to install the Rook Ceph cluster. Ensure you have kubectl configured for your Kubernetes cluster. ```sh kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.5.4/crds.yaml kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.5.4/common.yaml kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.5.4/operator.yaml kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.5.4/cluster.yaml ``` -------------------------------- ### Create Kuboard Database for OpenGauss Source: https://github.com/eip-work/kuboard-press/blob/master/v4/install/index.md This script sets up the Kuboard database and user within an OpenGauss instance. It specifies UTF8 encoding and PG compatibility. ```sql CREATE USER kuboard PASSWORD 'Kuboard123'; CREATE DATABASE kuboard OWNER=kuboard ENCODING='UTF8' DBCOMPATIBILITY='PG'; \c kuboard CREATE SCHEMA kuboard AUTHORIZATION kuboard; ``` -------------------------------- ### Create and Use a Namespace with kubectl Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/obj/namespaces.md These commands demonstrate how to create a new namespace and then deploy a pod within that specific namespace. Replace '' with the desired namespace name. ```bash kubectl run nginx --image=nginx --namespace= kubectl get pods --namespace= ``` -------------------------------- ### ReplicaSet Pod Selector Example Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/wl-replicaset/index.md Example of a label selector used by a ReplicaSet to identify Pods it should manage. Ensure `.spec.template.metadata.labels` matches this selector. ```yaml matchLabels: tier: frontend ``` -------------------------------- ### 套件描述文件示例 (addon.json) Source: https://github.com/eip-work/kuboard-press/blob/master/guide/addon/customize.md 此JSON文件定义了套件的基本信息、脚本、Kubernetes资源和附加文件。确保脚本和k8s文件的路径相对于此文件是正确的。 ```json { "name": "资源层监控套件", "id": "eip-monitor-system", "version": "0.1.1", "lastUpdate": "2019-12-11", "maintainer": "shaohq@foxmail.com", "scripts": ["system-addon.js"], "k8s": ["system-k8s.yaml"], "resources": ["resource/1621.json", "resource/1860.json", "resource/3146.json", "resource/8588.json"], "isGlobal": true, "info": { "description": "通过prometheus/grafana监控Kubernetes资源层的信息,包括CPU使用、内存使用、网络使用等信息。", "document": "https://github.com/eip-work/kuboard-addons/tree/master/repository/eip-monitor-system/0.1.1" } } ``` -------------------------------- ### User Impersonation Request Headers Example Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-advanced/sec/authenticate/readme.md Example of HTTP request headers used for user impersonation, including user, group, and extra fields. ```text Impersonate-User: jane.doe@example.com Impersonate-Group: developers Impersonate-Group: admins Impersonate-Extra-dn: cn=jane,ou=engineers,dc=example,dc=com Impersonate-Extra-acme.com%2Fproject: some-project Impersonate-Extra-scopes: view Impersonate-Extra-scopes: development ``` -------------------------------- ### Configure Hosts File (Linux/macOS) Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubectl.md Append an entry to the '/etc/hosts' file to map an IP address to a hostname. Replace 'x.x.x.x' with the actual IP address of the demo-master-a-1 and 'apiserver.demo' with the host from the cluster server URL. ```shell echo "x.x.x.x apiserver.demo" >> /etc/hosts ``` -------------------------------- ### Delete Existing Calico Installation Source: https://github.com/eip-work/kuboard-press/blob/master/install/upgrade-k8s/calico-3.8-3.9.md Remove the current Calico installation if the version is 3.8.2 or 3.8.x. Ensure you use the correct YAML file corresponding to your version. ```sh # 如果版本号是 v3.8.2 或者 v3.8.x,则删除命令如下 kubectl delete -f https://kuboard.cn/install-script/calico/calico-3.8.yaml ``` -------------------------------- ### Kubernetes 控制器伪代码 Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/service/network.md 此伪代码展示了 Kubernetes 控制器的工作循环:不断监控当前状态并与期望状态进行比较,然后采取行动以缩小差距。 ```go while true: X = currentState() Y = desiredState() if X == Y: return # Do nothing else: do(tasks to get to Y) ``` -------------------------------- ### Get Deployments using kubectl Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-basics/deploy-app.md Check the status and details of your Kubernetes Deployments using the kubectl get deployments command. This helps verify if the deployment was successful. ```sh kubectl get deployments ``` -------------------------------- ### Pod Owner References Example Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/gc.md This is an example output showing the ownerReferences field for a Pod created by a ReplicaSet. It indicates the Pod's owner is a ReplicaSet named 'my-repset'. ```yaml apiVersion: v1 kind: Pod metadata: ... ownerReferences: - apiVersion: apps/v1 controller: true blockOwnerDeletion: true kind: ReplicaSet name: my-repset uid: d9607e19-f88f-11e6-a518-42010a800195 ... ``` -------------------------------- ### Container Process Information Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/config/sec-ctx/con.md Example output showing processes running within a container. Note that the 'USER' column reflects the runAsUser setting (2000 in this case), overriding the Pod's setting (1000). ```text PID USER TIME COMMAND 1 2000 0:00 sleep 1h 6 2000 0:00 sh 11 2000 0:00 ps aux ... ``` -------------------------------- ### Display Resource Kind with Output Source: https://github.com/eip-work/kuboard-press/blob/master/t/cka/daily/011.md This command shows the resource type (e.g., `deployment.extensions`) along with the deployment details. It's useful when dealing with multiple resource types or to explicitly see the kind of object being listed. ```bash kubectl get deployments. --show-kind ``` -------------------------------- ### Install Rook-Ceph Cluster Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/persistent/ceph/rook-config-1.4.7.md Apply the common, operator, and cluster YAML files to install Rook-Ceph. Consider using docker-image-loader for faster image deployment, especially in air-gapped environments. ```sh kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.4.7/common.yaml kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.4.7/operator.yaml kubectl create -f https://kuboard.cn/statics/learning/ceph/rook-1.4.7/cluster.yaml ``` -------------------------------- ### Check Master Initialization Status (Shell) Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubernetes.md Execute these commands on the first master node to monitor the status of system pods and verify node readiness after initialization. Wait until all pods are in a Running state. ```shell # Only execute on the first master node # Execute the following command and wait for 3-10 minutes until all pods are in the Running state watch kubectl get pod -n kube-system -o wide # View the master node initialization results kubectl get nodes ``` -------------------------------- ### Configure Yum Repository for Kubectl on Linux Source: https://github.com/eip-work/kuboard-press/blob/master/install/install-kubectl.md Sets up the necessary YUM repository configuration for installing kubectl on RHEL-based Linux distributions. Ensure this configuration is correctly applied before proceeding with the installation. ```bash cat < /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF ``` -------------------------------- ### Get ReplicaSet Information with kubectl Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/wl-deployment/pause.md Use `kubectl get rs` to list ReplicaSets associated with your Deployments. This is useful for observing the state of pods managed by different ReplicaSet versions during a rollout. ```bash kubectl get rs ``` -------------------------------- ### Build and Push Docker Image (Shell Script) Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-practice/ocp/back-center.md These commands guide you through building the Docker image for the back-center application and pushing it to a Docker registry. Ensure you are in the back-center directory and logged into your Docker account. ```shell # 切换到 back-center 目录 cd /root/open-capacity-platform/web-portal/back-center # 使用你自己的 docker 用户名登录 docker login # 构建镜像 docker build -t ocpsample/back-center:latest . # 推送镜像 docker push ocpsample/back-center:latest ``` -------------------------------- ### Get Deployment Information with kubectl Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/wl-deployment/pause.md Use `kubectl get deployment` to view the current status of your Deployments. This command helps in verifying the desired, current, up-to-date, and available replica counts. ```bash kubectl get deployment ``` -------------------------------- ### lsblk -f Output Example Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/persistent/ceph/rook-config.md Example output of `lsblk -f` showing disk information. The `vdb` disk is available for Ceph OSDs as its FSTYPE is empty, while `vda` and its partitions are already formatted. ```sh lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT vda └─vda1 LVM2_member eSO50t-GkUV-YKTH-WsGq-hNJY-eKNf-3i07IB ├─ubuntu--vg-root ext4 c2366f76-6e21-4f10-a8f3-6776212e2fe4 / └─ubuntu--vg-swap_1 swap 9492a3dc-ad75-47cd-9596-678e8cf17ff9 [SWAP] vdb ``` -------------------------------- ### Delay Pod Startup Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-intermediate/workload/init-container.md A simple init container command to introduce a fixed delay before application containers start. Useful for scenarios requiring a timed startup sequence. ```sh sleep 60 ``` -------------------------------- ### Describe Ingress for Configuration Details Source: https://github.com/eip-work/kuboard-press/blob/master/learning/k8s-advanced/ts/deployment.md This command displays the configuration details of an Ingress resource, including its backend services, which is useful for debugging Ingress setup. ```bash kubectl describe ingress ```