開發方式的變化:docker-compose 遷移到 minikube

ponponon發表於2022-03-13

使用 kompose 轉義

下載安裝 kompose:地址

圖片.png

有各種各樣的版本供你選擇,總有一款適合你

注意:新版本的 kompose 砍掉了 up 和 down 兩個子命令,以前很多關於 kompose 把 docker-compose 專案直接遷移到 k8s 平臺的教程都沒有辦法使用了

具體情況參考:如何解決 unknown command "up" for "kompose"

輸入 kompose convert

圖片.png

使用

kubectl apply -f authentication-service-deployment.yaml,http-api-service-deployment.yaml,add-service-deployment.yaml
kubectl apply -f add-service-service.yaml,authentication-service-service.yaml,http-api-service-service.yaml
kubectl get pods -A
minikube image load ponponon/test-nameko-for-rabbitmq:1.0.1
minikube ssh
docker@minikube:~$ docker image ls
REPOSITORY                                                                             TAG       IMAGE ID       CREATED         SIZE
ponponon/test-nameko-for-rabbitmq                                                      1.0.1     eb717d2bfbaa   17 hours ago    1.1GB
nginx                                                                                  latest    c919045c4c2b   11 days ago     142MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver                     v1.23.1   b6d7abedde39   2 months ago    135MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy                         v1.23.1   b46c42588d51   2 months ago    112MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler                     v1.23.1   71d575efe628   2 months ago    53.5MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager            v1.23.1   f51846a4fd28   2 months ago    125MB
registry.cn-hangzhou.aliyuncs.com/google_containers/etcd                               3.5.1-0   25f8c7f3da61   4 months ago    293MB
registry.cn-hangzhou.aliyuncs.com/google_containers/coredns                            v1.8.6    a4ca41631cc7   5 months ago    46.8MB
registry.cn-hangzhou.aliyuncs.com/google_containers/coredns/coredns                    v1.8.6    a4ca41631cc7   5 months ago    46.8MB
registry.cn-hangzhou.aliyuncs.com/google_containers/pause                              3.6       6270bb605e12   6 months ago    683kB
registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetesui/dashboard             v2.3.1    e1482a24335a   8 months ago    220MB
registry.cn-hangzhou.aliyuncs.com/google_containers/dashboard                          <none>    e1482a24335a   8 months ago    220MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetesui/metrics-scraper       v1.0.7    7801cfc6d5c0   9 months ago    34.4MB
registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-scraper                    <none>    7801cfc6d5c0   9 months ago    34.4MB
registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-minikube/storage-provisioner   v5        6e38f40d628d   11 months ago   31.5MB
registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner                v5        6e38f40d628d   11 months ago   31.5MB
kubectl create  -f env-configmap.yaml          
─➤  kubectl describe configmap env                                                   
Name:         env
Namespace:    default
Labels:       io.kompose.service=add-service-env
Annotations:  <none>

Data
====
DATABASE_HOST:
----
192.168.31.203
kubectl apply -f authentication-service-deployment.yaml,http-api-service-deployment.yaml,add-service-deployment.yaml
─➤  kubectl get deployment,svc,pods
NAME                                     READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/add-service              1/1     1            1           15m
deployment.apps/authentication-service   1/1     1            1           15m
deployment.apps/http-api-service         1/1     1            1           15m

NAME                             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/authentication-service   ClusterIP   10.99.60.205     <none>        5002/TCP   29h
service/http-api-service         ClusterIP   10.104.237.146   <none>        5000/TCP   29h
service/kubernetes               ClusterIP   10.96.0.1        <none>        443/TCP    29h

NAME                                          READY   STATUS    RESTARTS   AGE
pod/add-service-79949489f7-kjm4m              1/1     Running   0          15m
pod/authentication-service-786df44c64-mjhtg   1/1     Running   0          15m
pod/http-api-service-5d6dd96ffb-2btxx         1/1     Running   0          15m

相關文章