Implementation of k8s deployment of docker container

Implementation of k8s deployment of docker container

Environment: (docker, k8s cluster), continue with the image of the java program started by docker last time as an example (https://www.jb51.net/article/189462.htm)

Push the created image to Docker's private repository

docker tag demo-img:latest localhost:5000/demo-img:1.0

docker push localhost:5000/demo-img:1.0 

k8s deploys the image k8s creates a namespace and secret

Create a namespace cl-test. Define the name according to your own naming convention. I use this for testing.

kubectl create namespace cl-test

After creating ns, we need to create a secret for this ns

kubectl create secret docker-registry regcred --docker-server=your registry ip:5000 --docker-username=root --docker-password=xxxx@ [email protected] -n cl-test

The console returns "secret/regcred created" to indicate successful creation.

Create a yaml file for the demo service. We put service and deployment in one yaml file.

---

apiVersion: v1
kind: Service
metadata:
 name: demo-service
 namespace: cl-test
 labels:
 app: demo-service
spec:
 type: NodePort
 ports:
 - port: 8701
 targetPort: 8701
 protocol: TCP
 name: http
 selector:
 app: demo-pod
---
apiVersion: apps/v1
kind: Deployment
metadata:
 name: demo-deployment
 namespace: cl-test
spec:
 selector:
 matchLabels:
  app: demo-pod
 replicas: 1
 template:
 metadata:
  labels:
  app: demo-pod
 spec:
  containers:
  - name: demo-container
  image: localhost:5000/demo-img:1.0 #The image name + version of the local private image library ports:
  - containerPort: 8701

start up

kubectl create -f demo.yaml

View Pods

kubectl get pod -n cl-test 

Check the pod log, which is exactly the log we displayed when Java was started before

This is the end of this article about the implementation of k8s deployment of docker containers. For more relevant k8s deployment docker content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to use docker to deploy spring boot and connect to skywalking
  • How to package the docker image, push it to the remote server and deploy it to k8s
  • How to deploy k8s in docker
  • Docker learning notes k8s deployment method
  • Skywalking containerized deployment of docker images to build k8s from testing to availability

<<:  JavaScript Basics Series: Functions and Methods

>>:  Detailed explanation of non-primary key column overflow monitoring in MySQL tables

Recommend

Stealing data using CSS in Firefox

0x00 Introduction A few months ago, I found a vul...

Inspiring Design Examples of Glossy and Shiny Website Design

This collection showcases a number of outstanding ...

Nine advanced methods for deduplicating JS arrays (proven and effective)

Preface The general methods are not listed here, ...

Detailed explanation of Alibaba Cloud security rule configuration

Two days ago, I took advantage of the Double 11 s...

VMware12 installs Ubuntu19.04 desktop version (installation tutorial)

1. Experimental description In the virtual machin...

Summary of commonly used CSS encapsulation methods

1. pc-reset PC style initialization /* normalize....

The reason why MySQL uses B+ tree as its underlying data structure

We all know that the underlying data structure of...

Vue uses filters to format dates

This article example shares the specific code of ...

Detailed explanation of the basic commands of Firewalld firewall in Centos7

1. Basics of Linux Firewall The Linux firewall sy...

MySQL database implements MMM high availability cluster architecture

concept MMM (Master-Master replication manager fo...