我正在尝试在Pod初始化期间将文件添加到Pod的磁盘中,但是没有运气。以下是用于部署Pod的部署文件。该文件已下载到永久卷,但Pod尚未进入就绪状态。几秒钟后,吊舱失效并被重建。再次开始了整个过程。
任何帮助将不胜感激。
let array_one = ["Hindi","English","Bengali","Telugu","Odia"]
let array_two = ["01","02","03","04","05"]
struct Language {
let name: String
let index: String
}
let languagesArray: [Language] = zip(array_one, array_two).map{Language(name: $0.0, index: $0.1)}
let language = "Hindi"
guard let languageAndId = languagesArray.first(where: {$0.name == language
}) else {
fatalError("Couldn't find the language")
}
let output = languageAndId.name + ", " + languageAndId.index
//prints "Hindi, 01"
答案 0 :(得分:2)
我试图在Pod初始化期间将文件添加到Pod的磁盘中,但是没有运气。
在这种情况下,您可能想使用InitContainers
。
从清单中判断,将执行主命令(复制文件,然后退出),以终止该过程中的容器(和附带的容器)。部署然后重新启动退出的Pod,并重复循环。如果改用function mousePressed() {
if (mouseButton == LEFT) {
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
grid[i][j].testX(mouseX, mouseY);
}
}
}
}
(具有与现在对主容器相同的定义和相同的PV),则应使用function Cell(x, y, w) {
this.x = x;
this.y = y;
this.w = w;
this.busy = true;
this.computer = true;
this.player = false;
}
Cell.prototype.show = function() {
stroke(0);
noFill();
rect(this.x, this.y, this.w-1, this.w-1);
if (this.player) {
line(this.x, this.y, this.x+this.w-1, this.y+this.w-1);
line(this.x, this.y+this.w-1, this.x+this.w-1, this.y);
}
}
Cell.prototype.testX = function(px, py) {
if (px >= this.x && px < this.x+this.w && py >= this.y && py < this.y+this.w ) {
this.player = true;
}
}
function mousePressed() {
if (mouseButton == LEFT) {
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
grid[i][j].testX(mouseX, mouseY);
}
}
}
}
function make2DArray(cols, rows) {
var arr = new Array(cols);
for (var i = 0; i < arr.length; i++) {
arr[i] = new Array(rows);
}
return arr;
}
var grid;
var rows;
var cols;
var w = 100;
function setup() {
createCanvas(300, 300);
cols = floor(width/w);
rows = floor(width/w);
grid = make2DArray(cols, rows);
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
grid[i][j] = new Cell(i * w, j * w, w);
}
}
}
function draw() {
background(255);
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
grid[i][j].show();
}
}
}
预先填充数据,直到运行完成,然后继续在常规模式下使用容器(应以不退出的主进程作为其命令/入口点)。
注意:如果您不想使用<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.js"></script>
或只是为了进行快速测试,则可以在copy语句后附加一个常规的不退出命令,并检查是否需要使用以下命令启动容器tty,具体取决于您的用例以及保持容器正常运行的方式。