我在erb模板中有以下条目:
# Lorem Ipsum...
<% unless @foo['bar'] == nil %>
<% @foo['bar'].each do |property, value| %>
<%= "zaz.#{property} #{value}" %>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这被解析为:
# Lorem Ipsum...
zaz.property value
Run Code Online (Sandbox Code Playgroud)
如何删除前导空格,以便在已解析的模板中不会缩进行?
我想避免使用类似的东西:
# Lorem Ipsum...
<% unless @foo['bar'] == nil %>
<% @foo['bar'].each do |property, value| %>
<%= "zaz.#{property} #{value}" %>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud) 从AWS文档中,我可以看到Fargate的AWS::ECS::TaskDefinition中需要CPU和Memory属性,但如果使用Fargate,则资源内的ContainerDefinition 中不需要。
这究竟是如何工作的?如果我不指定它,ContainerDefinition它将使用任务可用的尽可能多的资源?如果任务中只有一个容器......定义这些值是否有意义?如果需要它们,对我来说这似乎是多余和冗长的。
我在同一台机器上Elasticsearh,Logstash和Beat/ filebeat.
Filebeat配置为发送信息localhost:5043.
Logstash有一个管道配置侦听端口5043.
如果我跑了,netstat -tuplen我看到:
[root@elk bin]# netstat -tuplen | grep 5043
tcp6 0 0 :::5043 :::* LISTEN 994 147016 31435/java
Run Code Online (Sandbox Code Playgroud)
这意味着logstash加载了管道并正在侦听预期的端口.
如果我telnet要localhost和端口5043:
[root@elk bin]# telnet localhost 5043
Trying ::1...
Connected to localhost.
Escape character is '^]'.
^CConnection closed by foreign host.
[root@elk bin]#
Run Code Online (Sandbox Code Playgroud)
这意味着该端口是开放的.
但是,当我阅读filebeat日志时,我看到:
2017-02-15T17:35:32+01:00 INFO Home path: [/usr/share/filebeat] Config path: [/etc/filebeat] Data path: …Run Code Online (Sandbox Code Playgroud) 我可以用来terraform在中部署Kubernetes群集GKE。
然后,我将提供程序设置Kubernetes如下:
provider "kubernetes" {
host = "${data.google_container_cluster.primary.endpoint}"
client_certificate = "${base64decode(data.google_container_cluster.primary.master_auth.0.client_certificate)}"
client_key = "${base64decode(data.google_container_cluster.primary.master_auth.0.client_key)}"
cluster_ca_certificate = "${base64decode(data.google_container_cluster.primary.master_auth.0.cluster_ca_certificate)}"
}
Run Code Online (Sandbox Code Playgroud)
默认情况下,terraform与Kubernetes用户互动client,后者无权创建(例如)部署。因此,当我尝试通过以下方式应用更改时,出现此错误terraform:
Error: Error applying plan:
1 error(s) occurred:
* kubernetes_deployment.foo: 1 error(s) occurred:
* kubernetes_deployment.foo: Failed to create deployment: deployments.apps is forbidden: User "client" cannot create deployments.apps in the namespace "default"
Run Code Online (Sandbox Code Playgroud)
我不知道现在该如何进行,应该如何向client用户授予此权限?
如果将以下字段添加到提供程序,则我可以执行部署,尽管在阅读文档之后,这些凭据似乎用于HTTP与群集进行通信,如果通过Internet完成,则是不安全的。
username = "${data.google_container_cluster.primary.master_auth.0.username}"
password = "${data.google_container_cluster.primary.master_auth.0.password}"
Run Code Online (Sandbox Code Playgroud)
还有其他更好的方法吗?
kubernetes google-kubernetes-engine terraform-provider-gcp terraform-provider-kubernetes
我有以下代码:
# Assuming each element in foo is an array.
foo.each do |bar|
zaz = bar.first
# Other code using zaz, but not modifying it.
end
Run Code Online (Sandbox Code Playgroud)
局部变量是否会zaz在循环内的每次迭代中被修改,使其可变?我不确定 Ruby 在这里的行为。