1
2
3
|
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* minikube minikube minikube
|
kubectl config set-context minikube
Context "minikube" modified.
|
kubectl
kubectl controls the Kubernetes cluster manager.
Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/
Basic Commands (Beginner):
create Create a resource from a file or from stdin.
expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
run Run a particular image on the cluster
set Set specific features on objects
run-container Run a particular image on the cluster. This command is deprecated, use "run" instead
Basic Commands (Intermediate):
get Display one or many resources
explain Documentation of resources
edit Edit a resource on the server
delete Delete resources by filenames, stdin, resources and names, or by resources and label selector
Deploy Commands:
rollout Manage the rollout of a resource
rolling-update Perform a rolling update of the given ReplicationController
scale Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job
autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController
Cluster Management Commands:
certificate Modify certificate resources.
cluster-info Display cluster info
top Display Resource (CPU/Memory/Storage) usage.
cordon Mark node as unschedulable
uncordon Mark node as schedulable
drain Drain node in preparation for maintenance
taint Update the taints on one or more nodes
Troubleshooting and Debugging Commands:
describe Show details of a specific resource or group of resources
logs Print the logs for a container in a pod
attach Attach to a running container
exec Execute a command in a container
port-forward Forward one or more local ports to a pod
proxy Run a proxy to the Kubernetes API server
cp Copy files and directories to and from containers.
auth Inspect authorization
Advanced Commands:
apply Apply a configuration to a resource by filename or stdin
patch Update field(s) of a resource using strategic merge patch
replace Replace a resource by filename or stdin
convert Convert config files between different API versions
Settings Commands:
label Update the labels on a resource
annotate Update the annotations on a resource
completion Output shell completion code for the specified shell (bash or zsh)
Other Commands:
api-versions Print the supported API versions on the server, in the form of "group/version"
config Modify kubeconfig files
help Help about any command
plugin Runs a command-line plugin
version Print the client and server version information
Usage:
kubectl [flags] [options]
Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
|
kubectl [command] [TYPE] [NAME] [flags]
|
kubectl create namespace jenkins
|
cat jenkins-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: jenkins-deployment
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins:2.60.3
ports:
- containerPort: 8080
|
kubectl create -f jenkins-deployment.yaml --namespace=jenkins
deployment.extensions/jenkins-deployment created
|
kubectl describe deployments --namespace=jenkins
|
cat jenkins-service.yaml
apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
nodePort: 30000
selector:
app: jenkins
|
kubectl create -f jenkins-service.yaml --namespace=jenkins
|
kubectl get pods --namespace=jenkins
NAME READY STATUS RESTARTS AGE
jenkins-deployment-868cc579df-42lpn 1/1 Running 0 21m
|
kubectl log jenkins-deployment-868cc579df-42lpn --namespace=jenkins
|
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y jq
|
kubectl get job
job_name
|
kubectl get job job_name -o json | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | kubectl replace --force -f -
|
相关推荐
作者 | 孤弋 阿里云高级技术专家,负责 EDAS 的开发和用户体验优化工作。 导读:在上一篇文章《SpringCloud 应用在 Kubernetes 上的云上实践 – 开发篇》中讲到可以通过两个工具,轻松地将一个 SpringCloud 应用从初始化到本地运行。本篇文章,我们将介绍如何将上一篇文章中提到的应用在云上跑起来。 初始化集群 为了将应用运行在云端,首先我们需要一个 Kubernet
前言 哈喽,大家好,我是 Lorin,随着云平台的发展,Serverless 成为一个备注关注的话题,这一架构模型为开发人员提供了更简单、更灵活的方式来构建和部署应用程序,而无需过多关注底层基础设施的管理。本文将介绍什么是 Serverless,以及为什么它在现代应用开发中变得如此重要。 IaaS 与 PaaS 和SaaS 在 Serverless 兴起之前,IaaS(基础设施即服务)、PaaS(
Docker 解决了同一机器上的环境隔离问题,提高了运维部署的效率。 Vagrant 给开发提供一个统一的开发、测试、接近于完全隔离的环境。本文,主要讨论如何使用 Vagrant 搭建 Django 开发环境。版本:VirtualBox 5.0,Vagrant 1.8。1. 基本概念 1.1 Vagrant
在Web开发中,常会遇到数据导出的需求。这篇主要介绍如何快速将数据导出,并保存为Excel文件。1. 前端Web开发中,格式化数据常以table的形式展示。下面是一个人员薪酬信息表,以导出这份数据为例。姓名职位年龄薪水 Tiger NixonTiger Nixon System Architect 61 $320,800 Garrett Winters Accountant 63 $170,750
通常,我们需要在 GitHub 上进行一些操作,才能触发 GitHub Action。本篇将介绍一种通过 API 远程调用触发 GitHub Action 的方法。1. 常见的几种触发 GitHub Action 的方式下面是一个 GitHub Action 的示例:1 2 3 4 5 6 7 name: GitHub Actions Demo on: [push, pull_request] j
回到顶部