Home > Archives > k8s尝试

k8s尝试

Publish:

[root@dbg ~]# cd /usr/local/
[root@dbg local]# git clone https://github.com/rinormaloku/k8s-mastery.git

SA-FRONTEND

[root@dbg local]# cd k8s-mastery/sa-frontend/
[root@dbg sa-frontend]# npm install
[root@dbg sa-frontend]# npm start
[root@dbg sa-frontend]# npm run build
[root@dbg sa-frontend]# cd build/
[root@dbg build]# pwd
/usr/local/k8s-mastery/sa-frontend/build
[root@dbg build]# vim /etc/nginx/conf.d/default.conf

location / {
	#root   /usr/share/nginx/html;
	root   /usr/local/k8s-mastery/sa-frontend/build;
	index  index.html index.htm;
}

http://47.93.14.139/

SA-WEBAPP

[root@dbg ~]# cd /usr/local/k8s-mastery/sa-webapp/
[root@dbg sa-webapp]# yum install maven
[root@dbg sa-webapp]# mvn install
[root@dbg sa-webapp]# cd target/
[root@dbg target]# java -jar sentiment-analysis-web-0.0.1-SNAPSHOT.jar --sa.logic.api.url=http://localhost:5000
[root@dbg ~]# cd /usr/local/k8s-mastery/sa-logic/

SA-LOGIC

[root@dbg sa-logic]# cd sa/
[root@dbg sa]# python -m pip install -r requirements.txt 
[root@dbg sa]# python -m textblob.download_corpora
[root@dbg sa]# python sentiment_analysis.py 

以上三个地方的配置,在联合调试的时候,需要做一些灵活的思考和修改。

INSTALL DOCKER CE

[root@dbg ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@dbg ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@dbg ~]# yum install docker-ce
[root@dbg ~]# systemctl start docker
[root@dbg ~]# docker run hello-world

RUN DOCKER

[root@dbg ~]# docker login -u="username" -p="password"
[root@dbg ~]# cd /usr/local/k8s-mastery/sa-frontend/
[root@dbg sa-frontend]# docker build -f Dockerfile -t baoguoding/sentiment-analysis-fronted .
[root@dbg sa-frontend]# docker push baoguoding/sentiment-analysis-fronted
[root@dbg sa-frontend]# docker pull baoguoding/sentiment-analysis-fronted
[root@dbg sa-frontend]# docker run -d -p 80:80 baoguoding/sentiment-analysis-fronted

[root@dbg sa-frontend]# cd ../sa-webapp/
[root@dbg sa-webapp]# docker build -f Dockerfile -t baoguoding/sentiment-analysis-web-app .
[root@dbg sa-webapp]# docker run -d -p 8080:8080 -e SA_LOGIC_API_URL='http://47.93.14.139:5050' baoguoding/sentiment-analysis-web-app

[root@dbg sa-webapp]# cd ../sa-logic/
[root@dbg sa-logic]# docker build -f Dockerfile -t baoguoding/sentiment-analysis-logic .
[root@dbg sa-logic]# docker run -d -p 5050:5000 baoguoding/sentiment-analysis-logic

INSTALL VirtualBox

[root@dbg ~]# cd /etc/yum.repos.d
[root@dbg yum.repos.d]# wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo


[root@dbg ~]# yum install VirtualBox-5.2

Install Kubectl

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl

curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/

Install MINIKUBE

curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v0.24.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

RUN MINIKUBE

[root@dbg ~]# service docker start
[root@dbg ~]# export CHANGE_MINIKUBE_NONE_USER=true
[root@dbg ~]# minikube start --vm-driver=none --bootstrapper=localkube
[root@dbg ~]# minikube status
[root@dbg ~]# kubectl get nodes

[root@dbg ~]# journalctl -fu kubelet ---查看问题
[root@dbg ~]# minikube logs -f
[root@dbg ~]# docker rm -f $(docker ps -aq --filter name=k8s)
[root@dbg ~]# minikube stop
[root@dbg ~]# minikube delete
[root@dbg ~]# rm -rf ~/.minikube
[root@dbg ~]# rm -rf ~/.kube
[root@dbg ~]# rm -rf /etc/kubernetes

参考

三小时学会Kubernetes:容器编排详细指南

Get Docker CE for CentOS

安装Docker CE、安装最新版Docker

Install Minikube

Kubernetes 学习笔记之 MiniKube 安装

Minikube - Kubernetes本地实验环境

Day 1 前言 & 介紹Kubernetes

部署node节点

在CentOS7上使用二进制方式部署Kubernetes

kubectl安装(1.9版本)(解决国内安装kubectl失败)

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo