Install onepanel
Install onepanel
官方参考文档
https://docs.onepanel.ai/docs/deployment/configuration/files/
https://docs.onepanel.ai/docs/deployment/configuration/remote-microk8s/#configure-local-dns
https://docs.onepanel.ai/docs/deployment/configuration/remote-microk8s/
Git Blog
1 Install microk8s using the command line
sudo snap install microk8s --channel=1.21/stable --classic
sudo snap alias microk8s.kubectl kubectl
2 Make sure your current user has permissions to work with microk8s
.
sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER ~./kube
Configuring the proxy environment variables
启用proxy后需要在安装k8s基础容器后关闭代理
修改配置文件/etc/environment
$ sudo nano /etc/environment
HTTPS_PROXY=http://squid.internal:3128
HTTP_PROXY=http://squid.internal:3128
NO_PROXY=10.0.0.0/8,192.168.0.0/16,127.0.0.1,172.16.0.0/16
https_proxy=http://squid.internal:3128
http_proxy=http://squid.internal:3128
no_proxy=10.0.0.0/8,192.168.0.0/16,127.0.0.1,172.16.0.0/16
we need to configure NO_PROXY
and no_proxy
with the IP ranges the pods and services occupy
For the changes to take effect we need to restart MicroK8s:
microk8s stop
microk8s start
Wait for it to be ready.
microk8s status --wait-ready
3 Enable the following required add-ons:
sudo microk8s enable storage dns rbac
4 Update API server config(optional)
sudo nano /var/snap/microk8s/current/args/kube-apiserver
Add to the top
--service-account-signing-key-file=${SNAP_DATA}/certs/serviceaccount.key
--service-account-key-file=${SNAP_DATA}/certs/serviceaccount.key
--service-account-issuer=api
--service-account-api-audiences=api,nats
Restart microk8s for the changes to take effect
microk8s stop && microk8s start && microk8s status --wait-ready
5 Enable microk8s addons
sudo microk8s enable storage dns rbac
microk8s status --wait-ready
Check node
and pod
status
-------------node status----------
root@rtzh-virtual-k8s:~# sudo microk8s.kubectl get node
NAME STATUS ROLES AGE VERSION
rtzh-virtual-k8s Ready <none> 18m v1.21.13-3+cbc10c94808907
------------pod status-------------
root@rtzh-virtual-k8s:~# sudo microk8s.kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-f7868dd95-hfmz5 1/1 Running 0 19m
kube-system calico-node-k8kk6 1/1 Running 0 19m
kube-system hostpath-provisioner-566686b959-lk6hg 1/1 Running 0 2m55s
kube-system coredns-7f9c69c78c-2fsrt 1/1 Running 0 2m53s
Configure DNS
i. Edit the resolvconf
sudo nano /var/snap/microk8s/current/args/kubelet
Add to the top
--resolv-conf=/run/systemd/resolve/resolv.conf
ii. Edit coredns configmap so we point to the resolv.conf file
microk8s kubectl edit cm coredns -n kube-system
Set the forward section to:
forward . /etc/resolv.conf 8.8.8.8 8.8.4.4
iii. Restart microk8s
microk8s stop && microk8s start && microk8s status --wait-ready
Install Onepanel#
Install
# startvpn curl -sLO https://github.com/onepanelio/onepanel/releases/latest/download/opctl-linux-amd64 chmod +x opctl-linux-amd64 sudo mv ./opctl-linux-amd64 /usr/local/bin/opctl
Initialize Onepanel
opctl init --provider microk8s \ --enable-metallb \ --artifact-repository-provider s3
params.yaml
按照模板中的说明进行填充,并参阅配置文件部分以获取更多详细信息。# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Generated with Onepanel CLI # CLI version: v1.0.2 # Command: opctl init --provider microk8s --enable-metallb --artifact-repository-provider s3 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Component: Onepanel # Description: Onepanel application information # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - application: defaultNamespace: example domain: onepanel.test fqdn: app.onepanel.test insecure: true nodePool: label: node.kubernetes.io/instance-type options: - name: 'Local machine' value: 'local' provider: microk8s # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Component: Artifact repository # Description: S3 compatible object storage for storing files across Onepanel # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - artifactRepository: s3: # S3 access key accessKey: 'minio' # Name of bucket, example: my-bucket bucket: 'mybucket' # Your bucket here endpoint: 'minio.example.svc.cluster.local' # replace `example` with your namespace # Change to true if endpoint does NOT support HTTPS insecure: true # Key Format for objects stored by Workflows. This can reference Workflow variables keyFormat: artifacts/{{workflow.namespace}}/{{workflow.name}}/{{pod.name}} publicEndpoint: 10.1.131.146:9000 # The IP address from minio # Bucket region, this can be anything since it is running locally region: us-west-2 # S3 secret key secretKey: 'minio123' # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Component: cert-manager # Description: automatically creates and renews TLS certificates using Let's Encrypt # Docs: https://onepanelio.github.io/core-docs/docs/deployment/configuration/tls # CLI flag: --enable-cert-manager # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - certManager: email: test@test.com # Not used in local deployments as certs are generated locally # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Component: Application and kubernetes load balancing on non-cloud deployments. # Description: MetalLB, LoadBalancer # CLI flag: --enable-metallb # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - metalLb: addresses: - 192.168.99.0/32
Deploy onepanel
issue
kfserving controller image pull unauthorizedModifying the kfserving version before deploying onepanel
If you have already executed
kubeconfig opctl apply
, delete cache filerm -rf .onepanel/kubernetes.yaml rm -rf .onepanel/manifests/cache/
nano .onepanel/manifests/v1.0.2/kfserving/base/kfserving.yaml # change - gcr.io/kfserving/kfserving-controller:v0.6.0 to + kfserving/kfserving-controller:v0.6.1
microk8s config > kubeconfig KUBECONFIG=./kubeconfig opctl apply
Expose Onepanel using Nginx
First, install nginx.
sudo apt-get install nginx
Then, configure nginx to expose Onepanel
sudo nano /etc/nginx/sites-available/default
Change this
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
to
location / {
client_max_body_size 0; # No size limit to upload requests
proxy_pass http://192.168.99.0; # the ip address you gave metallb
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_request_buffering off;
}
Then, stop editing and run
sudo nginx -s reload
Configure Local DNS
/etc/hosts
添加一行
For this example, we will assume the IP is: 10.9.98.213
# <ip> <fqdn>
10.9.98.213 app.onepanel.test
常用命令
microk8s.kubectl describe node # Describe a node
microk8s.kubectl describe node ml #跟踪Node节点信息
microk8s.kubectl describe pods -A #显示所有pod信息
microk8s.kubectl describe pod kfserving-controller-manager-0 -n kfserving-system #显示指定pod详细信息
microk8s.kubectl delete deployment kfserving-models-web-app -n kfserving-system #删除deployment
microk8s.kubectl delete pod kfserving-controller-manager-0 -n kfserving-system #删除pod
microk8s.kubectl get pods --all-namespaces #同下
microk8s kubectl get pods -A # 获取所有pod执行状态
microk8s kubectl get deployment -A # 查看所有部署
microk8s stop && microk8s start && microk8s status --wait-ready #重启
microk8s.kubectl logs -f onepanel-core-ui-7d9b8d5954-bbtzv -n onepanel #查看日志