vi /etc/hosts hostnamectl set-hostname kubehost hostname -f sed -i '/[[:space:]]swap[[:space:]]/ s/^[^#]/#&/' /etc/fstab swapoff -a swapon --show tee /etc/modules-load.d/k8s.conf < /dev/null sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml systemctl edit containerd [Service] LimitNOFILE=1048576 LimitNOFILESoft=1048576 systemctl restart containerd systemctl enable containerd systemctl is-active containerd grep 'SystemdCgroup = true' /etc/containerd/config.toml apt install -y apt-transport-https ca-certificates curl gpg mkdir -p -m 755 /etc/apt/keyrings curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.36/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.36/deb/ /" | tee /etc/apt/sources.list.d/kubernetes.list apt update apt install -y kubelet kubeadm kubectl apt-mark hold kubelet kubeadm kubectl kubeadm version kubelet --version kubectl version --client kubeadm init --pod-network-cidr=10.244.0.0/16 mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config kubectl get nodes watch 'kubectl get nodes' kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml kubectl get pods -n kube-flannel kubectl get pods -n kube-system kubectl get nodes -o wide kubectl run --image=hello-world hello-world kubectl get pods kubectl describe nodes | grep Taints kubectl taint nodes --all node-role.kubernetes.io/control-plane:NoSchedule- kubectl taint nodes --all node-role.kubernetes.io/master:NoSchedule- kubectl get pods kubectl delete pod/hello-world apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: standard provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer mkdir /k8sdata /k8sdata2 /k8sdata3 chmod 777 /k8sdata* tee pv.yaml << EOF apiVersion: v1 kind: PersistentVolume metadata: name: manual-pv1 spec: capacity: storage: 30Gi accessModes: - ReadWriteOnce hostPath: path: "/k8sdata" storageClassName: standard EOF # modify for pv2 pv3 kubectl apply -f pv.yaml # repeat for pv2 pv3 HELM_BUILDKITE_APT_KEY_ID="DDF78C3E6EBB2D2CC223C95C62BA89D07698DBC6" apt-get install curl gpg apt-transport-https --yes curl -fsSL https://packages.buildkite.com/helm-linux/helm-debian/gpgkey > "${TMPDIR:-/tmp}/helm.gpg" # Ensure that the key ID matches to prevent a repository compromise from establishing an attacker controlled key if [ "$(gpg --show-keys --with-colons "${TMPDIR:-/tmp}/helm.gpg" | awk -F: '$1 == "fpr" {print $10}' | head -n 1)" != "${HELM_BUILDKITE_APT_KEY_ID}" ]; then echo "ERROR: Unexpected Helm APT key ID: potential key compromise"; exit 1; fi cat "${TMPDIR:-/tmp}/helm.gpg" | gpg --dearmor | tee /usr/share/keyrings/helm.gpg > /dev/null echo "deb [signed-by=/usr/share/keyrings/helm.gpg] https://packages.buildkite.com/helm-linux/helm-debian/any/ any main" | tee /etc/apt/sources.list.d/helm-stable-debian.list apt-get update apt-get install helm helm repo add mongodb https://mongodb.github.io/helm-charts helm install kubernetes-operator mongodb/mongodb-kubernetes --namespace mongodb --create-namespace # Other than namespace, other values are specified with --set param.child=value # See: https://www.mongodb.com/docs/kubernetes/current/reference/helm-operator-settings/ kubectl config get-contexts kubectl config set-context $(kubectl config current-context) --namespace=mongodb kubectl create secret generic ops-manager-admin-secret --from-literal=Username="dba" --from-literal=Password="ChangeMe123%" --from-literal=FirstName="dba" --from-literal=LastName="dba" tee ops-manager.yaml < storclas.yaml kubectl apply -f storclas.yaml kubectl describe pod/ops-manager-db-2 kubectl get storageclass kubectl describe storageclass kubectl get pods init 0 shutdown -h now kubectl get nodes history # krew plugin --- apiVersion: apps/v1 kind: Deployment metadata: name: private-registry namespace: default spec: replicas: 1 selector: matchLabels: app: private-registry template: metadata: labels: app: private-registry spec: containers: - name: registry image: registry:2 ports: - containerPort: 5000 volumeMounts: - name: registry-storage mountPath: /var/lib/registry volumes: - name: registry-storage emptyDir: {} # hostPath: # path: /mnt/vpath # persistentVolumeClaim: # claimName: clm1 --- apiVersion: v1 kind: Service metadata: name: private-registry namespace: default spec: selector: app: private-registry ports: - protocol: TCP port: 5000 targetPort: 5000 --- apiVersion: v1 kind: Service metadata: name: ext-private-registry namespace: default spec: type: NodePort selector: app: private-registry ports: - port: 5000 targetPort: 5000 nodePort: 30050