返回值
【摘要】 [root@master opt]# kubectl cluster-info&&kubectl -n istio-system get all&&kubectl -n kubevirt get deploymentKubernetes control plane is running at https://192.168.100.9:6443CoreDNS is running at ht...
1.k8s集群搭建
[root@master opt]# kubectl cluster-info&&kubectl -n istio-system get all&&kubectl -n kubevirt get deployment
Kubernetes control plane is running at https://192.168.100.9:6443
CoreDNS is running at https://192.168.100.9:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Warning: kubevirt.io/v1 VirtualMachineInstancePresets is now deprecated and will be removed in v2.
NAME READY STATUS RESTARTS AGE
pod/grafana-56bdf8bf85-7tpfc 1/1 Running 0 101s
pod/istio-egressgateway-85649899f8-sj7ng 1/1 Running 0 107s
pod/istio-ingressgateway-f56888458-zwwkx 1/1 Running 0 107s
pod/istiod-64848b6c78-ng7j6 1/1 Running 0 111s
pod/jaeger-76cd7c7566-p5kvc 1/1 Running 0 101s
pod/kiali-646db7568f-h72hs 1/1 Running 0 101s
pod/prometheus-85949fddb-wrgzv 2/2 Running 0 101s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/grafana ClusterIP 10.102.10.27 <none> 3000/TCP 101s
service/istio-egressgateway ClusterIP 10.105.222.230 <none> 80/TCP,443/TCP 107s
service/istio-ingressgateway LoadBalancer 10.96.174.198 <pending> 15021:32532/TCP,80:31499/TCP,443:31007/TCP,31400:32040/TCP,15443:30054/TCP 107s
service/istiod ClusterIP 10.101.196.75 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 111s
service/jaeger-collector ClusterIP 10.107.74.88 <none> 14268/TCP,14250/TCP,9411/TCP 101s
service/kiali ClusterIP 10.101.181.39 <none> 20001/TCP,9090/TCP 101s
service/prometheus ClusterIP 10.103.108.235 <none> 9090/TCP 101s
service/tracing ClusterIP 10.104.136.170 <none> 80/TCP,16685/TCP 101s
service/zipkin ClusterIP 10.102.250.83 <none> 9411/TCP 101s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/grafana 1/1 1 1 101s
deployment.apps/istio-egressgateway 1/1 1 1 107s
deployment.apps/istio-ingressgateway 1/1 1 1 107s
deployment.apps/istiod 1/1 1 1 111s
deployment.apps/jaeger 1/1 1 1 101s
deployment.apps/kiali 1/1 1 1 101s
deployment.apps/prometheus 1/1 1 1 101s
NAME DESIRED CURRENT READY AGE
replicaset.apps/grafana-56bdf8bf85 1 1 1 101s
replicaset.apps/istio-egressgateway-85649899f8 1 1 1 107s
replicaset.apps/istio-ingressgateway-f56888458 1 1 1 107s
replicaset.apps/istiod-64848b6c78 1 1 1 111s
replicaset.apps/jaeger-76cd7c7566 1 1 1 101s
replicaset.apps/kiali-646db7568f 1 1 1 101s
replicaset.apps/prometheus-85949fddb 1 1 1 101s
NAME READY UP-TO-DATE AVAILABLE AGE
virt-api 2/2 2 2 26s
virt-operator 2/2 2 2 51s
mariadb测试
[root@master Pig]# docker run -d --name mariadb-test pig-mariadb:v1.0 && sleep 10 && docker exec mariadb-test mysql -uroot -proot -e "show databases;" && docker rm -f mariadb-test
b120dec3aa0d4e4e52e88d217abab0dfbf1ac956d19943aaf5ca899bebf84e3c
Database
information_schema
mysql
performance_schema
pig
pig_codegen
pig_config
pig_job
test
mariadb-test
redis测试
[root@master Pig]# docker run -d --name redis-test pig-redis:v1.0 && sleep 10 && docker exec redis-test egrep -v '^$|^#' /etc/redis.conf && docker rm -f redis-test
cb48e6bd12777e19aed2228551ce37654e96149aa6981443696ddc0318ec29b4
bind 0.0.0.0
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis/redis.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
redis-test
pig测试
[root@master Pig]# docker run -d --name=pig-test pig-service:v1.0 && sleep 20 && docker exec pig-test java -version && docker rm -f pig-test
20e60496a542047454f2f5096d6bc86f9cf7be9461998dbcf80e8fd40e133e69
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
pig-test
nginx测试
[root@master Pig]# docker run -d --name=nginx-test --restart=always pig-ui:v1.0 && docker cp nginx-test:/data /tmp && ls /tmp/data && rm -rf /tmp/data && docker rm -f nginx-test
dd94c9763221ba8c8274136403f3c47eddbdf6c1c7ebe2a90799c1aa7f8b5f74
cdn css favicon.ico fonts img index.html js svg
nginx-test
docker-compose运行
[root@master Pig]# curl -L http://$(hostname -i):8888 | grep title
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1963 100 1963 0 0 3576k 0 --:--:-- --:--:-- --:--:-- 1916k
<!DOCTYPE html><html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black><meta name=format-detection content="telephone=no"><meta http-equiv=X-UA-Compatible content="chrome=1"><link rel=stylesheet href=cdn/animate/3.5.2/animate.css><link rel=stylesheet href=cdn/avue/avue.css><link rel=icon href=favicon.ico><link href=css/chunk-2104ec0a.e263568c.css rel=prefetch><link href=css/page.85141055.css rel=prefetch><link href=css/views.449c88da.css rel=prefetch><link href=js/chunk-2104ec0a.bc31aa99.js rel=prefetch><link href=js/chunk-2d0e4caf.05a04604.js rel=prefetch><link href=js/page.85d99d9a.js rel=prefetch><link href=js/views.b9368873.js rel=prefetch><link href=css/app.9f967307.css rel=preload as=style><link href=css/chunk-vendors.99a2f327.css rel=preload as=style><link href=js/app.ee68caff.js rel=preload as=script><link href=js/chunk-vendors.077b21fe.js rel=preload as=script><link href=css/chunk-vendors.99a2f327.css rel=stylesheet><link href=css/app.9f967307.css rel=stylesheet></head><body><noscript><strong>很抱歉,如果没有 JavaScript 支持,网站将不能正常工作。请启用浏览器的 JavaScript 然后继续。</strong></noscript><div id=app><div class=avue-home><div class=avue-home__main><img class=avue-home__loading src=./svg/loading-spin.svg alt=loading><div class=avue-home__title>正在加载资源</div><div class=avue-home__sub-title>初次加载资源可能需要较多时间 请耐心等待</div></div><div class=avue-home__footer><a href=https://pig4cloud.com/zh-cn target=_blank>Copyright © 2020 pig4cloud.com</a></div></div></div><script src=js/chunk-vendors.077b21fe.js></script><script src=js/app.ee68caff.js></script></body></html>
服务网格:创建ingress gateway
[root@master ~]# curl -L http://$(hostname -i):$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')/productpage
<!DOCTYPE html>
<html>
<head>
<title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="static/bootstrap/css/bootstrap-theme.min.css">
</head>
<body>
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">BookInfo Sample</a>
</div>
<button type="button" class="btn btn-default navbar-btn navbar-right" data-toggle="modal" href="#login-modal">Sign
in</button>
</div>
</nav>
<!---
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header pull-left">
<a class="navbar-brand" href="#">Microservices Fabric BookInfo Demo</a>
</div>
<div class="navbar-header pull-right">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<button type="button" class="btn btn-default navbar-btn pull-right" data-toggle="modal" data-target="#login-modal">Sign in</button>
</div>
</div>
</div>
-->
<div id="login-modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Please sign in</h4>
</div>
<div class="modal-body">
<form method="post" action='login' name="login_form">
<p><input type="text" class="form-control" name="username" id="username" placeholder="User Name"></p>
<p><input type="password" class="form-control" name="passwd" placeholder="Password"></p>
<p>
<button type="submit" class="btn btn-primary">Sign in</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</p>
</form>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h3 class="text-center text-primary">The Comedy of Errors</h3>
<p>Summary: <a href="https://en.wikipedia.org/wiki/The_Comedy_of_Errors">Wikipedia Summary</a>: The Comedy of Errors is one of <b>William Shakespeare's</b> early plays. It is his shortest and one of his most farcical comedies, with a major part of the humour coming from slapstick and mistaken identity, in addition to puns and word play.</p>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h4 class="text-center text-primary">Book Details</h4>
<dl>
<dt>Type:</dt>paperback
<dt>Pages:</dt>200
<dt>Publisher:</dt>PublisherA
<dt>Language:</dt>English
<dt>ISBN-10:</dt>1234567890
<dt>ISBN-13:</dt>123-1234567890
</dl>
</div>
<div class="col-md-6">
<h4 class="text-center text-primary">Book Reviews</h4>
<blockquote>
<p>An extremely entertaining play by Shakespeare. The slapstick humour is refreshing!</p>
<small>Reviewer1</small>
<font color="black">
<!-- full stars: -->
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<!-- empty stars: -->
</font>
</blockquote>
<blockquote>
<p>Absolutely fun and entertaining. The play lacks thematic depth when compared to other plays by Shakespeare.</p>
<small>Reviewer2</small>
<font color="black">
<!-- full stars: -->
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<!-- empty stars: -->
<span class="glyphicon glyphicon-star-empty"></span>
</font>
</blockquote>
<dl>
<dt>Reviews served by:</dt>
<u>reviews-v2-65c4dc6fdc-mgf9f</u>
</dl>
</div>
</div>
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="static/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
$('#login-modal').on('shown.bs.modal', function () {
$('#username').focus();
});
</script>
</body>
</html>
服务网格:流量管理
[root@master ~]# kubectl get destinationrule reviews -o jsonpath={.spec.subsets}
[{"labels":{"version":"v1"},"name":"v1"},{"labels":{"version":"v2"},"name":"v2"},{"labels":{"version":"v3"},"name":"v3"}]
[root@master ~]# kubectl get ns default --show-labels
NAME STATUS AGE LABELS
default Active 41m istio-injection=enabled,kubernetes.io/metadata.name=default
[root@master ~]# kubectl describe vs reviews
Name: reviews
Namespace: default
Labels: <none>
Annotations: <none>
API Version: networking.istio.io/v1beta1
Kind: VirtualService
Metadata:
Creation Timestamp: 2024-09-26T03:17:57Z
Generation: 1
Managed Fields:
API Version: networking.istio.io/v1alpha3
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.:
f:kubectl.kubernetes.io/last-applied-configuration:
f:spec:
.:
f:hosts:
f:http:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2024-09-26T03:17:57Z
Resource Version: 7679
UID: 1b8fd977-31fe-461b-9e27-56b82809d874
Spec:
Hosts:
reviews
Http:
Route:
Destination:
Host: reviews
Subset: v1
Events: <none>
服务网格:基于用户身份的路由
[root@master ~]# kubectl describe vs reviews
Name: reviews
Namespace: default
Labels: <none>
Annotations: <none>
API Version: networking.istio.io/v1beta1
Kind: VirtualService
Metadata:
Creation Timestamp: 2024-09-26T03:17:57Z
Generation: 2
Managed Fields:
API Version: networking.istio.io/v1alpha3
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:spec:
.:
f:hosts:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2024-09-26T03:17:57Z
API Version: networking.istio.io/v1beta1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:kubectl.kubernetes.io/last-applied-configuration:
f:spec:
f:http:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2024-09-26T03:19:59Z
Resource Version: 8034
UID: 1b8fd977-31fe-461b-9e27-56b82809d874
Spec:
Hosts:
reviews
Http:
Match:
Headers:
End - User:
Exact: jason
Route:
Destination:
Host: reviews
Subset: v2
Route:
Destination:
Host: reviews
Subset: v1
Events: <none>
服务网格:注入延迟故障
[root@master ~]# kubectl describe vs ratings
Name: ratings
Namespace: default
Labels: <none>
Annotations: <none>
API Version: networking.istio.io/v1beta1
Kind: VirtualService
Metadata:
Creation Timestamp: 2024-09-26T03:17:57Z
Generation: 2
Managed Fields:
API Version: networking.istio.io/v1alpha3
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.:
f:kubectl.kubernetes.io/last-applied-configuration:
f:spec:
.:
f:hosts:
f:http:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2024-09-26T03:21:52Z
Resource Version: 8361
UID: a28e4b8a-072a-4e07-a4a8-517a0025c72d
Spec:
Hosts:
ratings
Http:
Fault:
Delay:
Fixed Delay: 7s
Percentage:
Value: 100
Match:
Headers:
End - User:
Exact: jason
Route:
Destination:
Host: reviews
Subset: v2
Route:
Destination:
Host: ratings
Subset: v1
Events: <none>
创建vm
[root@master ~]# kubectl describe vm
Name: fedora-vm
Namespace: default
Labels: <none>
Annotations: kubevirt.io/latest-observed-api-version: v1
kubevirt.io/storage-observed-api-version: v1alpha3
API Version: kubevirt.io/v1
Kind: VirtualMachine
Metadata:
Creation Timestamp: 2024-09-26T03:25:03Z
Finalizers:
kubevirt.io/virtualMachineControllerFinalize
Generation: 1
Managed Fields:
API Version: kubevirt.io/v1alpha3
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
f:kubevirt.io/latest-observed-api-version:
f:kubevirt.io/storage-observed-api-version:
f:finalizers:
.:
v:"kubevirt.io/virtualMachineControllerFinalize":
Manager: Go-http-client
Operation: Update
Time: 2024-09-26T03:25:03Z
API Version: kubevirt.io/v1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.:
f:kubectl.kubernetes.io/last-applied-configuration:
f:spec:
.:
f:running:
f:template:
.:
f:spec:
.:
f:domain:
.:
f:devices:
.:
f:disks:
f:interfaces:
f:resources:
.:
f:requests:
.:
f:memory:
f:networks:
f:volumes:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2024-09-26T03:25:03Z
API Version: kubevirt.io/v1alpha3
Fields Type: FieldsV1
fieldsV1:
f:status:
.:
f:conditions:
f:created:
f:desiredGeneration:
f:observedGeneration:
f:printableStatus:
f:ready:
f:volumeSnapshotStatuses:
Manager: Go-http-client
Operation: Update
Subresource: status
Time: 2024-09-26T03:25:14Z
Resource Version: 9078
UID: 612d81dd-a481-4877-a307-8fa798fb044d
Spec:
Running: true
Template:
Metadata:
Creation Timestamp: <nil>
Spec:
Domain:
Devices:
Disks:
Disk:
Bus: virtio
Name: containerdisk
Interfaces:
Masquerade:
Name: default
Machine:
Type: q35
Resources:
Requests:
Memory: 1Gi
Networks:
Name: default
Pod:
Volumes:
Container Disk:
Image: 192.168.100.9/library/fedora-virt:v1.0
Image Pull Policy: IfNotPresent
Name: containerdisk
Status:
Conditions:
Last Probe Time: <nil>
Last Transition Time: 2024-09-26T03:25:13Z
Status: True
Type: Ready
Last Probe Time: <nil>
Last Transition Time: <nil>
Status: True
Type: LiveMigratable
Created: true
Desired Generation: 1
Observed Generation: 1
Printable Status: Running
Ready: true
Volume Snapshot Statuses:
Enabled: false
Name: containerdisk
Reason: Snapshot is not supported for this volumeSource type [containerdisk]
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 25s virtualmachine-controller Started the virtual machine by creating the new virtual machine instance fedora-vm
创建ingress
[root@master ~]# kubectl describe ingress -n ing-internal
Name: pong
Labels: <none>
Namespace: ing-internal
Address:
Ingress Class: nginx
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
*
/hello test:5678 (<error: endpoints "test" not found>)
Annotations: nginx.ingress.kubernetes.io/rewrite-target: /
Events: <none>
部署owncloud
[root@master owncloud]# kubectl get pv,pvc
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/owncloud-pv 5Gi RWO Retain Bound default/owncloud-pvc 41s
persistentvolume/pv-test 1Gi RWO Delete Available 7m32s
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/owncloud-pvc Bound owncloud-pv 5Gi RWO 41s
[root@master owncloud]# kubectl get ConfigMap
NAME DATA AGE
istio-ca-root-cert 1 77m
kube-root-ca.crt 1 87m
owncloud-config 2 48s
[root@master owncloud]# kubectl get Secret
NAME TYPE DATA AGE
owncloud-db-password Opaque 1 13s
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)