IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> create own image and use SSH connection -> 正文阅读

[开发工具]create own image and use SSH connection

create Dockerfile

FROM ubuntu:latest
RUN apt-get update
RUN apt-get install openssh-server -y
RUN service ssh start

#edit sshd_config
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
RUN sed -i 's/#PasswordAuthentication no/PasswordAuthentication no/' /etc/ssh/sshd_config

#make directory
RUN mkdir -p ~/.ssh

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

push the image

create a Repositories on docker hub (https://hub.docker.com)

?docker build and tag

docker build -t firstimage .
docker tag own-image ziyiyi/firstimage:version1

then login

docker login

do the docker push

$ docker push ziyiyi/firstimage:version1
The push refers to repository [docker.io/ziyiyi/firstimage]
ec95150d5656: Pushed 
575cafaa406d: Pushed 
f54ff46ec837: Pushed 
f25e4e9f70f3: Pushed 
0b36e911075e: Pushed 
d2a953fa5513: Pushed 
c652dae3e282: Pushed 
7f5cbd8cc787: Pushed 
version1: digest: sha256:232730e524038e13284eedaba418b150c06b64e7362fb95477d212a39baa0fbe size: 1992

you can see the image

$ docker image ls
REPOSITORY                    TAG       IMAGE ID       CREATED          SIZE
own-image                     latest    8bed6064f82e   16 seconds ago   224MB

create a SSH-key

ssh-keygen

see the public key

$ cat /home/ziyi/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDG/v77BlpbZsxlsm+Zh8hYzjzKVWNPlv/E7p1lP7mfM+5auj9VR7zHTLLQgMmK7ApwCk0ob89kxSTOIYdAog+Wmkrq8bsTS+6jm66lZ9Cew2hqgcXceLHgdpJHV+KKgYNKTT9JNTQlvWLzgkVdxewUhIbEkZ28IBAPv3/RwPjELJr5siElIUxbd/gbWeI8K6mM8IE07TAK5A3LdfJylvTi8oZ7MEZS78tZQEz9BtTqUQMIyU0LDfzGlgrmo3OxThwZsXxsifSJY+3t54Go2Feq0cqJ0r0KOsxnKqhpOdMTbWyE8ZvlUWt2ODZNV/FduuQ54U8IYuqgR1QNMvhjgJe8nd8FvSLYwnoQQhDNswjfaxiVFpAk2p9Et/hNYHcq1szrmHu2JKEIaq5geAh/KI2d1nwZThNjf8SrceCeqfmtddFWoRZcchzY5l6Wezi/712VlkN3u/1gJmNPnKdE1p2D082Oudyl9XUvzAbBg+kKQ0mY5cafr1FxXhzpz+Kg2vM= ziyi@ubuntu

##create configMap and add the public key to?it

apiVersion: v1
kind: ConfigMap
metadata:
  name: ssh-config
data:
  authorized_keys: |
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDG/v77BlpbZsxlsm+Zh8hYzjzKVWNPlv/E7p1lP7mfM+5auj9VR7zHTLLQgMmK7ApwCk0ob89kxSTOIYdAog+Wmkrq8bsTS+6jm66lZ9Cew2hqgcXceLHgdpJHV+KKgYNKTT9JNTQlvWLzgkVdxewUhIbEkZ28IBAPv3/RwPjELJr5siElIUxbd/gbWeI8K6mM8IE07TAK5A3LdfJylvTi8oZ7MEZS78tZQEz9BtTqUQMIyU0LDfzGlgrmo3OxThwZsXxsifSJY+3t54Go2Feq0cqJ0r0KOsxnKqhpOdMTbWyE8ZvlUWt2ODZNV/FduuQ54U8IYuqgR1QNMvhjgJe8nd8FvSLYwnoQQhDNswjfaxiVFpAk2p9Et/hNYHcq1szrmHu2JKEIaq5geAh/KI2d1nwZThNjf8SrceCeqfmtddFWoRZcchzY5l6Wezi/712VlkN3u/1gJmNPnKdE1p2D082Oudyl9XUvzAbBg+kKQ0mY5cafr1FxXhzpz+Kg2vM=
kubectl create -f xxxxx.yaml

##make a file

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

create Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: application-deployment
spec:
  selector:
    matchLabels:
      app: application
  replicas: 1
  template:
    metadata:
      labels:
        app: application
    spec:
      runtimeClassName: kata-qemu
      containers:
      - name: application
        image: ziyiyi/firstimage:version1
        ports:
        - containerPort: 22 
=====================================delete====================================       
        volumeMounts:
        - name: ssh-volume
          subPath: authorized_keys
          mountPath: ~/.ssh/authorized_keys
      volumes:
      - name: ssh-volume
        configMap:
          name: ssh-config
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  labels:
    app: application
spec:
  runtimeClassName: kata-qemu
  containers:
  - name: application
    image: ziyiyi/firstimage:version1
    ports:
    - containerPort: 22 

open tunnel?

open a new terminal in?order to?expose the LoadBalancer

minikube tunnel

create server

apiVersion: v1
kind: Service
metadata:
  name: ssh-service
spec:
  type: LoadBalancer
  ports:
  - port: 22222
    targetPort: 22
    name: lb
  selector:
    app: application

get service

$ kubectl get service
NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP    PORT(S)           AGE
ssh-service            LoadBalancer   10.107.127.107   <pending>     22222:31331/TCP   38m

?load up public key to server

ssh-copy-id -i ~/.ssh/id_rsa.pub root@{externalIP}

if the external-IP always pending

$ minikube service ssh-service
|-----------|-------------|-------------|-----------------------------|
| NAMESPACE |    NAME     | TARGET PORT |             URL             |
|-----------|-------------|-------------|-----------------------------|
| default   | ssh-service |       22222 | http://192.168.39.176:31331 |
|-----------|-------------|-------------|-----------------------------|
🎉  Opening service default/ssh-service in default browser...

then we can get the external-IP

check the connection

ssh -p 22222 root@{externalIP}

when unable to connect to the server

Unable to connect to the server: dial tcp 192.168.39.176:8443: connect: no route to host

?restart the minikube

minikube start
  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-09-15 02:12:56  更:2022-09-15 02:13:11 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/25 22:47:31-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码