在创建部署时,我目前正在尝试找到一个应该将容器的环境变量外部化到配置映射中的原因。因此,不要使用定义环境变量
env:
- name: LANGUAGE
value: "English"
Run Code Online (Sandbox Code Playgroud)
在deployment.yaml中使用
env:
- name: LANGUAGE
valueFrom:
configMapKeyRef:
name: language
key: LANGUAGE
Run Code Online (Sandbox Code Playgroud)
或者
envFrom:
- configMapRef:
name: env-configmap
Run Code Online (Sandbox Code Playgroud)
还有一个额外的 configmap.yaml ,如下所示:
apiVersion: v1
kind: ConfigMap
metadata:
name: env-configmap
data:
LANGUAGE: English
Run Code Online (Sandbox Code Playgroud)
当然,当使用机密值时,应该从机密中读取它们,但这不适用于非机密变量。我看到的唯一优点是我可以重用这些配置映射,但除此之外,它只会使图表变得更加复杂,因为我现在必须确保 Pod 重新启动等......
那么:使用ConfigMaps读取环境变量还有哪些优点呢?
我正在尝试在我的Web服务器中实现自签名证书,并且它已经在使用firefox和chrome(都来自服务器本身和远程计算机)了……但是我无法使其与Java一起使用。我已经创建了一个包含证书的密钥库文件,但是每次尝试连接到服务器时,它都会给我一个SSLHandshakeException:javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address 192.168.178.71 found
我用于此测试的代码是:
public static void main(String[] args) {
System.setProperty("javax.net.ssl.keyStore", HTTPStest.class.getResource("keystore.jks").getFile());
System.setProperty("javax.net.ssl.keyStorePassword", "lead");
URL url;
InputStream is = null;
BufferedReader br;
String line;
try {
url = new URL("https://192.168.178.71/");
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (is != …Run Code Online (Sandbox Code Playgroud) 有没有一种工作方法(我听说从更新 7.0 开始有一些变化)来显示带有标签的纬度/经度给定位置的标记?
geo:?q=latitude, longitude (Label)不起作用...
我正在尝试在链接文件夹中的文件中创建一个JSONArray到Android项目,而eclipse突然(之前没有这样做)给我错误:调用需要API级别19(当前最小值为14) :new org.json.JSONArray
它发生的代码如下:
String[] s = (save_val.trim().equals(""))?new String[]{}:save_val.split("\n");
JSONObject o = null;
if (!Arrays.equals(s, save_names)){
new JSONArray(s); // this is where the error is shown
Run Code Online (Sandbox Code Playgroud)
编辑:解决方案实际上这个方法在API 19之前没有引入,但是如果你使用(如我的情况)字符串数组或其他promitives你可以简单地做:
JSONArray s_values = new JSONArray();
for (int i = 0; i < s.length; i++){
s_values.put(yourarray[i]);
}
Run Code Online (Sandbox Code Playgroud)
这应该不会慢
我正在尝试为特定列设置渲染器,但不知何故此渲染器并未用于渲染该列。对此有什么解释吗?
tabledata = new LendDataTable();
table.setModel(tabledata);
TableColumn xx = table.getColumnModel().getColumn(3);
xx.setCellRenderer(new BookBackRenderer());//here it doesn't (there are 7 rows in total)
table.setDefaultRenderer(Integer.class, new BookBackRenderer());// here it works
add(table, BorderLayout.CENTER);
public class BookBackRenderer extends DefaultTableCellRenderer {
/**
*
*/
private static final long serialVersionUID = 1L;
public BookBackRenderer() {
// TODO Auto-generated constructor stub
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
System.out.println(column);
return super.getTableCellRendererComponent(table, value.toString() + "xy", isSelected, hasFocus, row, column);
} …Run Code Online (Sandbox Code Playgroud) java ×3
android ×2
api ×1
certificate ×1
google-maps ×1
ip ×1
json ×1
jtable ×1
kubernetes ×1
ssl ×1
swing ×1