问题描述
我正在使用kubespray在内部设置k8s集群。
我正在尝试使用CIS Benchmark文档强化kubernetes集群。
对于import React,{ useState } from 'react';
import {
View,Image,Text,TextInput,StyleSheet,SafeAreaView,KeyboardAvoidingView,} from 'react-native';
import { TouchableOpacity,ScrollView } from 'react-native-gesture-handler';
import profile from '../assets/IMG_7767.psd'
import UserStore from '../store/UserStore'
interface Props {
}
const Profile: React.FC<Props> = () => {
const { user } = UserStore
const [firstName,setFirstName] = useState(user[0].firstName)
const [lastName,setLastName] = useState(user[0].lastName)
const [location,setLocation] = useState(user[0].location)
const [description,setDescription] = useState(user[0].description)
const userObj = {
firstName: firstName,lastName: lastName,location: location,description: description
}
return (
<SafeAreaView style={styles.blue}>
<KeyboardAvoidingView>
<ScrollView>
<View style={styles.center}>
<View style={styles.head}>
<Text style={styles.headText}>Profile Details</Text>
</View>
<View style={styles.shadow}>
<Image source={profile} style={styles.profileImage}/>
</View>
<View style={styles.formField}>
<Text style={styles.formText}>First Name</Text>
<TextInput
style={styles.textInput}
value={firstName}
onChange={(e) => setFirstName(e.currentTarget)}
/>
</View>
<View style={styles.formField}>
<Text style={styles.formText}>Last Name</Text>
<TextInput
style={styles.textInput}
value={lastName}
onChange={(e) => setLastName(e.target.value)}
/>
</View>
<View style={styles.formField}>
<Text style={styles.formText}>Location</Text>
<TextInput
style={styles.textInput}
value={location}
onChange={(e) => setLocation(e.target.value)}
/>
</View>
<View style={styles.formField}>
<Text style={styles.formText}>Description</Text>
<TextInput
style={styles.textArea}
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
</View>
<TouchableOpacity style={styles.mainButton} onPress={()=> user[0].update(userObj)}>
<Text style={styles.mainButtonText}>Save</Text>
</TouchableOpacity>
</View>
</ScrollView>
</KeyboardAvoidingView>
</SafeAreaView>
)
}
参数,我在apiserver和kubelet之间建立了TLS连接。然后,我在主节点上编辑了API服务器容器规范文件--kubelet-certificate-authority
,并为证书颁发机构设置了/etc/kubernetes/manifests/kube-apiserver.yaml
参数,如下所示:--kubelet-certificate-authority
但是,由于已知错误,我不再能够(使用头盔)进行顶部部署吊舱:
[centos @ infra-vm〜] $掌舵清单 错误:转发端口:错误升级连接:错误拨号后端:x509:无法验证192.168.33.143的证书,因为它不包含任何IP SAN
--kubelet-certificate-authority=/etc/kubernetes/ssl/apiserver.crt
是主节点IP地址。
所以我真的不知道问题出在哪里。
192.168.33.143
有人可以帮忙弄清楚到底是怎么回事吗?
解决方法
首先,/etc/kubernetes/ssl/apiserver.crt
不是有效的CA证书。
CA将具有:
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature,Key Encipherment,Certificate Sign
通知Certificate Sign
扩展名,允许对证书进行签名。
您看到此错误:cannot validate certificate for 192.168.33.143 because it doesn't contain any IP SANs
,因为kubelet正在使用自签名证书在端口10250上提供https流量,并且正在使用无效的证书对其进行验证。
那你应该怎么做才能使它工作呢?
- 使用
/etc/kubernetes/ssl/ca.crt
为具有有效IP SAN的kubelet签名新证书。 - 设置
--kubelet-certificate-authority=/etc/kubernetes/ssl/ca.crt
(有效的CA)。 - 在
/var/lib/kubelet/config.yaml
(kubelet配置文件)中,设置tlsCertFile
和tlsPrivateKeyFile
指向新创建的kubeletcrt
和key
文件。