我正在 k8 客户端中创建一个 pod,并制作一个手表以在 pod 完成时收到通知,以便我可以读取 pod 的日志。观看界面似乎没有在频道上提供任何事件。这是代码,我将如何收到通知,即 pod 状态现已完成并已准备好读取日志
func readLogs(clientset *kubernetes.Clientset) {
// namespace := "default"
// label := "cithu"
var (
pod *v1.Pod
// watchface watch.Interface
err error
)
// returns a pod after creation
pod, err = createPod(clientset)
fmt.Println(pod.Name, pod.Status, err)
if watchface, err = clientset.CoreV1().Pods(namespace).Watch(metav1.ListOptions{
LabelSelector: pod.Name,
}); err != nil {
log.Fatalf(err.Error())
}
// How do I get notified when the pod.Status == completed
}
Run Code Online (Sandbox Code Playgroud) 我的 docker 文件看起来像这样:
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang
# Install our Go dependencies
RUN go get -u golang.org/x/oauth2...
ENTRYPOINT /go/bin/...
Run Code Online (Sandbox Code Playgroud)
我的基本应用程序将在 golang 上运行,但我需要从 golang 访问 python 脚本进行一些处理。如何在 docker 容器中安装 python3 并使用 pip 安装一些 python 依赖项。
Spec: v1.PodSpec{
Containers: []v1.Container{
v1.Container{
Name: podName,
Image: deploymentName,
ImagePullPolicy: "IfNotPresent",
Ports: []v1.ContainerPort{},
Env: []v1.EnvVar{
v1.EnvVar{
Name: "RASA_NLU_CONFIG",
Value: os.Getenv("RASA_NLU_CONFIG"),
},
v1.EnvVar{
Name: "RASA_NLU_DATA",
Value: os.Getenv("RASA_NLU_DATA"),
},
},
Resources: v1.ResourceRequirements{},
},
},
RestartPolicy: v1.RestartPolicyOnFailure,
},
Run Code Online (Sandbox Code Playgroud)
我想提供相应的资源限制,例如:
Run Code Online (Sandbox Code Playgroud)resources: limits: cpu: "1" requests: cpu: "0.5" args: - -cpus - "2"
我该怎么做。我尝试添加Limits及其映射键值对,但这似乎是一个嵌套的结构。关于如何在kube client go中提供资源似乎没有任何示例。
func main(){
bytearray:=[]byte{"data"}
reader := bytes.NewReader(stdout.Bytes())
transfer(reader)
}
Function 2
func transfer(reader *Reader){
bytearray:= //How do I get the original byte array?
}
Run Code Online (Sandbox Code Playgroud)
基本上我想使用读取器或写入器将字节数组从一个函数发送到另一个函数