如何更新kubernetes复制控制器?

时间:2015-12-16 09:29:13

标签: kubernetes

我使用复制控制器运行pods,现在我想编辑配置,如更改环境值并保留rc的名称。

<?php
ob_start();
include_once("php_includes/check_login_status.php");
include_once("php_includes/password.php");

// If user is already logged in, header that weenis away
if($user_ok == true){
    header("location: home.php?u=".$_SESSION["username"]);
    exit();
}
?><?php
// AJAX CALLS THIS LOGIN CODE TO EXECUTE
if(isset($_POST["e"])){
    // CONNECT TO THE DATABASE
    include_once("php_includes/db_conx.php");
    // GATHER THE POSTED DATA INTO LOCAL VARIABLES AND SANITIZE
    $e = mysqli_real_escape_string($db_conx, $_POST['e']);
    $p =  $_POST['p'];
    //$pw = password_hash($p, PASSWORD_BCRYPT);
    $pw = $p;
    // GET USER IP ADDRESS
    $ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));
    $online="online";
    // FORM DATA ERROR HANDLING
    if($e == "" || $p == ""){
        echo "login_failed";
        exit();
    } else {
    // END FORM DATA ERROR HANDLING
        $sql = "SELECT id, username, password FROM users WHERE email='$e' AND activated='1' OR username='$e' AND activated='1' LIMIT 1";
        $query = mysqli_query($db_conx, $sql);
        $row = mysqli_fetch_row($query);
        $db_id = $row[0];
        $db_username = $row[1];
        $db_pass_str = $row[2];

        if (password_verify($pw, $db_pass_str)){
            // CREATE THEIR SESSIONS AND COOKIES
            $_SESSION['userid'] = $db_id;
            $_SESSION['username'] = $db_username;
            $_SESSION['password'] = $db_pass_str;
            setcookie("id", $db_id, strtotime( '+30 days' ), "/", "", "", TRUE);
            setcookie("user", $db_username, strtotime( '+30 days' ), "/", "", "", TRUE);
            setcookie("pass", $db_pass_str, strtotime( '+30 days' ), "/", "", "", TRUE); 
            // UPDATE THEIR "IP" AND "LASTLOGIN" FIELDS
            $online = "online";
            $sql = "UPDATE users SET status='$online', SET ip='$ip', lastlogin=now() WHERE username='$db_username' LIMIT 1";
            $query = mysqli_query($db_conx, $sql);
            echo $db_username;
            exit();
        } else {
            echo "login_failed";
            exit();
        }
    }
    exit();
}
?>
<form class="col s12" id="loginform" onsubmit="return false;">
      <div class="row">
        <div class="input-field col s8">
          <i class="mdi-action-account-circle prefix"></i>
          <input type="text" id="email" onfocus="emptyElement('status')" maxlength="88"  class="validate">
          <label for="icon_prefix">Username or Email</label>
        </div>
        </div>
         <div class="row">
        <div class="input-field col s8">
          <i class="mdi-editor-mode-edit prefix"></i>
          <input type="password" id="password" onfocus="emptyElement('status')" maxlength="255" class="validate">
          <label for="icon_telephone">Password</label>
        </div>
      </div>
      <div class="row">
       <button class="btn blue waves-effect waves-light right" id="loginbtn" onclick="login()" type="submit" >Login </button>

      <div id="status"></div>

      </div>
    </form>

例如,我将服务转移到新服务器,只想将env apiVersion: v1 kind: ReplicationController metadata: name: backend spec: replicas: 3 template: spec: containers: - name: backend image: myproject/backend ports: - containerPort: 8080 env: - name: USER_ENDPOINT value: "http://10.0.7.29:10000" 的值更改为USER_ENDPOINT

现在我只知道跟随删除rc并重新创建rc,但在生产中我不会阻止它。

我尝试http://10.0.7.30:30100但是没有用,因为我想保留复制控制器的名称。

我该怎么办?

请提出解决方案,谢谢。

2 个答案:

答案 0 :(得分:2)

您可以使用kubectl edit编辑资源:

Usage:
  kubectl edit (RESOURCE/NAME | -f FILENAME) [flags]

Examples:
  # Edit the service named 'docker-registry':
  $ kubectl edit svc/docker-registry

  # Use an alternative editor
  $ KUBE_EDITOR="nano" kubectl edit svc/docker-registry

  # Edit the service 'docker-registry' in JSON using the v1 API format:
  $ kubectl edit svc/docker-registry --output-version=v1 -o json
来自kubectl帮助的

^^

答案 1 :(得分:0)

您可以使用HTTP PATCH方法部分更新RC,如此(假设您的RC位于default命名空间中):

PATCH /api/v1/namespaces/default/replicationcontrollers/backend

另请参阅API Reference