我正在尝试在 Ubuntu 22.04 服务器上安装我的第一个 kubernetes 集群。我正在按照此链接( https://www.cloudsigma.com/how-to-install-and-use-kubernetes-on-ubuntu-20-04/ )给出的说明进行操作。 当然,这实际上适用于 Ubuntu 20.04,但我认为它应该足够接近。
我在步骤#6,我刚刚在控制节点上执行了“INIT”命令(sudo kubeadm init --pod-network-cidr=10.255.0.0/16){尚未到达工作节点然而} 。我注意到有时(相当频繁)“kubectl”执行失败:
<nonrootuser>@k8s-cluster1-control1:~/kubernetes$ kubectl get pods -A
The connection to the server <controlNodeIPAddress>.1:6443 was refused - did you specify the right host or port?
Run Code Online (Sandbox Code Playgroud)
当它起作用时,我看到:
<nonrootuser>@k8s-cluster1-control1:~/kubernetes$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6d4b75cb6d-qmcg7 0/1 Pending 0 8m7s
kube-system coredns-6d4b75cb6d-z6ks5 0/1 Pending 0 8m7s
kube-system etcd-k8s-cluster1-control1 1/1 Running 13 (4m55s ago) 6m4s
kube-system kube-apiserver-k8s-cluster1-control1 1/1 Running 16 (3m43s ago) 9m14s …Run Code Online (Sandbox Code Playgroud) 作为学习Haskell的一部分,我正在尝试实现与Lists相关的各种函数的自己版本.现在我被困在init函数上.Haskell中的init函数返回List中除最后一个元素之外的所有元素.
这是我到目前为止所做的.
init' :: [Int] -> [Int]
init' [] = error "This function cannot be applied to an empty list"
init' [x] = [x]
init' (x:xs) = x : init' xs
Run Code Online (Sandbox Code Playgroud) 我有一个自定义的UIViewController子类,它被推送到UINavigationController堆栈上.我想在初始化/推送时添加一些我自己的数据.我是不是该
a)用我的数据作为参数写一个自定义的init方法,像这样?
MyCustomViewControllerSubclass.m:
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle myCustomData:(NSData *)data{
if(self = [super initWithNibName:nibName bundle:nibName]){
//do stuff with my data
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
或者b)在我的viewcontroller中添加一个属性来存储我的自定义数据,然后在初始化后添加它?
在这些方法之一中是否存在一些优势/劣势,还是有另一种方法可以做到这一点?
回复非常高兴!
我创建了一个新的gem:https://github.com/tntwebsolutions/ts3query
在我的init.rb文件中我require是主lib文件,这应该在加载rails应用程序时自动加载gem.但是,当我启动服务器时,它会接收init.rb文件未加载.
在我的申请中,我有这个Gemfile:
gem "ts3query", "~> 0.2.1"
Run Code Online (Sandbox Code Playgroud)
并在我这样做application_controller.rb:
@query = TS3Query.connect :password => password
Run Code Online (Sandbox Code Playgroud)
但后来我得到了这个错误:
uninitialized constant ApplicationController::TS3Query
Run Code Online (Sandbox Code Playgroud)
如果我这样做:
require 'TS3Query'
@query = TS3Query.connect :password => password
Run Code Online (Sandbox Code Playgroud)
它确实有效.但我无法弄清楚,我必须在我的gem上更改加载require 'TS3Query'rails应用程序时加载的内容.
可能重复:
指针作为第二个参数而不是返回指针?
我看到了很多:
Monkey* test = malloc(sizeof(Monkey));
Monkey_New(test);
Run Code Online (Sandbox Code Playgroud)
让init函数返回指针会不会更清晰?
Monkey* test = Monkey_New();
Run Code Online (Sandbox Code Playgroud)
为什么经常以第一种方式完成?
我有这个脚本,我想在启动守护进程之前切换到用户"terraria".我无法弄清楚该怎么做.我的研究让我使用bash脚本su my_user -c,但我认为这不适用于这种情况.
#!/bin/bash
# Terraria daemon
# chkconfig: 345 20 80
# description: Terraria Server
# processname: TerrariaServer.exe
DAEMON_PATH="/usr/Terraria"
DAEMON=TerrariaServer.exe
DAEMONOPTS="-world This_Land.wld -port 7777 "
NAME=TerrariaServer
DESC="Terraria Server"
PIDFILE=/var/run/TerrariaServer.pid
SCRIPTNAME=/etc/init.d/Terraria-Server
case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=`mono $DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
#echo "Saving PID" $PID " to " $PIDFILE
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status) …Run Code Online (Sandbox Code Playgroud) 我跑的时候
root@Nano:/etc/init.d# ./utserver
Run Code Online (Sandbox Code Playgroud)
这个脚本是http://pastebin.com/c7gxFdci,它给了我这个输出
": invalid option"
Run Code Online (Sandbox Code Playgroud)
无论论证如何完成.
public struct Style {
public var test : Int?
public init(_ build:(Style) -> Void) {
build(self)
}
}
var s = Style { value in
value.test = 1
}
Run Code Online (Sandbox Code Playgroud)
在声明变量时给出错误
Cannot find an initializer for type 'Style' that accepts an argument list of type '((_) -> _)'
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么这不起作用,这对我来说似乎是合法的代码
为了记录,这也无济于事
var s = Style({ value in
value.test = 1
})
Run Code Online (Sandbox Code Playgroud) class A {
private var value: Int
init(value: Int) {
self.value = value
}
}
Run Code Online (Sandbox Code Playgroud)
我们有A类,我用A.init(值:5)和A(值:5)创建这个对象有什么区别?谢谢