我正在尝试在kubernetes集群上安装一个helm软件包,该集群据称已禁用RBAC.我收到了一个权限错误提示clusterroles.rbac.authorization.k8s.io
,如果启用了 RBAC,这就是我所期望的.
有没有办法检查kubectl
RBAC是否真的被禁用?
我尝试过的:
kubectl describe nodes --all-namespaces | grep -i rbac
:什么都没有出现kubectl describe rbac --all-namespaces | grep -i rbac
:什么都没有出现kubectl config get-contexts | grep -i rbac
:什么都没有出现k get clusterroles
它说"找不到资源",而不是错误信息.这是否意味着,RBAC 被启用?kuebctl describe cluster
不是一件事我知道这可能是xy问题,因为我正在安装的helm软件包可能需要启用RBAC.但是,我仍然想知道如何检查它是否启用/禁用.
我正在尝试测试一个服务类,它在内部使用Spring AMQP连接对象.此连接对象由Spring注入.但是,我不希望我的单元测试实际上与AMQP代理通信,因此我使用Mockito注入连接对象的模拟.
/**
* The real service class being tested. Has an injected dependency.
*/
public class UserService {
@Autowired
private AmqpTemplate amqpTemplate;
public final String doSomething(final String inputString) {
final String requestId = UUID.randomUUID().toString();
final Message message = ...;
amqpTemplate.send(requestId, message);
return requestId;
}
}
/**
* Unit test
*/
public class UserServiceTest {
/** This is the class whose real code I want to test */
@InjectMocks
private UserService userService;
/** This is a dependency of the real …
Run Code Online (Sandbox Code Playgroud) 我想监控集群中持久卷的磁盘使用情况。我正在使用CoreOS Kube Prometheus。仪表板正在尝试使用名为kubelet_volume_stats_capacity_bytes的指标进行查询,该指标从 v1.12 开始的 Kubernetes 版本不再可用。
我正在使用 Kubernetes 版本 v1.13.4 和hostpath-provisioner根据持久卷声明来配置卷。我想访问每个持久卷的当前磁盘使用指标。
kube_persistentvolumeclaim_resource_requests_storage_bytes可用,但它仅以字节为单位显示持久声明请求
container_fs_usage_bytes没有完全涵盖我的问题。
metrics kubernetes prometheus persistent-volumes kubernetes-pvc
我正在尝试使用 Micrometer.io 和 Spring Boot 2.0.0.RELEASE 来生成 Prometheus 指标。
当我尝试将 List 的大小公开为 Gauge 时,它一直显示 NaN。在文档中它说;
您有责任持有对您使用 Gauge 测量的状态对象的强引用。
我尝试了一些不同的方法,但我无法解决问题。这是我的一些试验代码。
import io.micrometer.core.instrument.*;
import io.swagger.backend.model.Product;
import io.swagger.backend.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@RestController
@RequestMapping("metrics")
public class ExampleController {
private AtomicInteger atomicInteger = new AtomicInteger();
private ProductService productService;
private final Gauge productGauge;
@Autowired
public HelloController(ProductService productService,
MeterRegistry registry) {
this.productService = productService;
createGauge("product_gauge", productService.getProducts(), registry);
}
private void createGauge(String metricName, List<Product> products,
MeterRegistry registry) {
List<Product> products = productService.getProducts();
// …
Run Code Online (Sandbox Code Playgroud) 我正在使用以下配置创建一个 docker 图像。图像准备好后,我想将 JAVA_OPTS 传递给我的 docker 容器,以便它可以传递给我的 Spring Boot 应用程序。每当我尝试启动容器时,我都会收到“运行时创建失败:container_linux.go:348:启动容器进程导致”exec:\“java $JAVA_OPTS\”:在 $PATH 中找不到可执行文件“:未知”错误。我错过了什么吗?任何帮助真的很感激
文件
FROM openjdk:8-jdk-alpine
LABEL maintainer="myname@test.com"
# Add a volume pointing to /tmp
VOLUME /tmp
# Make port 8080 available to the world outside this container
EXPOSE 8080
# The application's jar file
ARG JAR_FILE=target/my.jar
# Add the application's jar to the container
ADD ${JAR_FILE} my.jar
ENV JAVA_OPTS=""
# Run the jar file
ENTRYPOINT ["java $JAVA_OPTS","-Djava.security.egd=file:/dev/./urandom","-jar","/my.jar"]
Run Code Online (Sandbox Code Playgroud)
docker-compose
version: '2.1'
services:
service1:
hostname: test
domainname: mydomain.com
image: myimage:latest
container_name: …
Run Code Online (Sandbox Code Playgroud) java jvm spring-boot docker-compose spring-boot-docker-plugin
我要将图像修补到初始化容器上
我的图片存储在名为$ IMAGE_NAME的变量中
当我跑步
kubectl修补程序部署production-art-backend -p {“ spec”:{“ template”:{“ spec”:{“ initContainers”:[{“ name”:“ run-migrations”,“ image”:“ $ IMAGE_NAME” }]}}}}
会将图片修补为“ IMAGE_NAME”,而不是变量IMAGE_NAME中的值,如何动态修补映像?
java ×3
kubernetes ×3
kubectl ×2
prometheus ×2
spring-boot ×2
jvm ×1
metrics ×1
micrometer ×1
mockito ×1
patch ×1
rbac ×1
spring ×1
unit-testing ×1