k3s使用&helm简单使用

k3s&helm

curl https://releases.rancher.com/install-docker/19.03.sh | sh
#curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

curl -sfL https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -

yum -y install docker-ce-19.03.7-3.el7
systemctl enable docker && systemctl start docker  && systemctl status docker

#优化
cat >/etc/docker/daemon.json <<EOF 
{
    "registry-mirrors": [
        "http://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com"
    ]
}
EOF


[root@vm ~]# docker pull redis:5.0.6-alpine
#报错一
Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid
[root@vm ~]# hwclock --show
Wed 28 Sep 2022 10:39:04 AM CST  -0.951797 seconds
[root@vm ~]# hwclock --set --date '05/15/2023 14:46:30'
[root@vm ~]# date
Wed Sep 28 10:39:56 CST 2022
[root@vm ~]# hwclock --hctosys
[root@vm ~]# clock -w
[root@vm ~]# reboot
#报错二
error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/...
[root@vm ~]# vim /etc/resolv.conf
nameserver 8.8.8.8


systemctl daemon-reload  && systemctl restart docker


systemctl daemon-reload  && systemctl restart docker

#docker pull registry.cn-beijing.aliyuncs.com/ilemonrain/pause-amd64:3.1
#docker tag registry.cn-beijing.aliyuncs.com/ilemonrain/pause-amd64:3.1 k8s.gcr.io/pause:3.1


vim /etc/profile
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
source /etc/profile

[root@sentry k3s]# cp /etc/rancher/k3s/k3s.yaml /root/.kube/config

https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz
[root@vm ~]# tar xf helm-3.6.0.tar.gz
[root@vm ~]# mv linux-amd64/helm /usr/local/bin/
[root@vm ~]# helm repo add stable http://mirror.azure.cn/kubernetes/charts
"stable" has been added to your repositories
[root@vm ~]# helm search repo  nginx



[root@sentry k3s]# helm install sentry sentry/sentry --version 19.3.0
[root@os1 /]# curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@os1 /]# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            3:24.0.2-1.el7                      docker-ce-stable

[root@os1 /]# yum -y install docker-ce-24.0.2-1.el7     #替换 ".x86_64 3:" 成 "-" 连接

#优化
[root@os1 /]# cat >/etc/docker/daemon.json <
{
    "registry-mirrors": [
        "http://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com"
    ]
}
EOF
[root@os1 /]# systemctl enable docker && systemctl start docker  && systemctl status docker

#k3s
[root@os1 /]# curl -sfL https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
kubectl get pod 
[root@os1 /]# cp /etc/rancher/k3s/k3s.yaml /root/.kube/config

wget  https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz
tar xf helm-v3.6.3-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin
helm install my  --debug --dry-run ./sentry >my.yaml

helm install my   ./sentry   --timeout 10m
helm uninstall my

启动时,K3s 会检查 /etc/rancher/k3s/ 中是否存在 registries.yaml 文件,并指示 containerd 使用该文件中定义的镜像仓库。如果你想使用私有的镜像仓库,你需要在每个使用镜像仓库的节点上以 root 身份创建这个文件。

你可能感兴趣的:(kubenetes,linux,运维,kubernetes)