aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/common/readinessCheck
diff options
context:
space:
mode:
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>2021-02-25 14:17:55 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2021-03-03 19:52:17 +0000
commit82f041d3a261436735c4206f2c3630ccb294c31a (patch)
tree285762006ddb83ae4fbd58a7beb237fbaa965dac /kubernetes/common/readinessCheck
parenta380f597fc80fee083ce2d8bf2ca408a660fba1b (diff)
[COMMON][READINESS] Fix user and group
readiness check can be launched in a lot of various situation. Especially, it can be runned on deployments / statefulsets where the user and group are fixed. But python code underneath can work only when user is set to "onap" as requirements are installed only for this specific user. This patch forces the user and group to the desired one. Issue-ID: OOM-2694 Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com> Change-Id: Ie70f8e851c30f530fd7a0d6e34ee5bda9274e874
Diffstat (limited to 'kubernetes/common/readinessCheck')
-rw-r--r--kubernetes/common/readinessCheck/templates/_readinessCheck.tpl3
-rw-r--r--kubernetes/common/readinessCheck/values.yaml3
2 files changed, 6 insertions, 0 deletions
diff --git a/kubernetes/common/readinessCheck/templates/_readinessCheck.tpl b/kubernetes/common/readinessCheck/templates/_readinessCheck.tpl
index 95de6ec29f..71201a1cc6 100644
--- a/kubernetes/common/readinessCheck/templates/_readinessCheck.tpl
+++ b/kubernetes/common/readinessCheck/templates/_readinessCheck.tpl
@@ -67,6 +67,9 @@
- name: {{ include "common.name" $dot }}{{ ternary "" (printf "-%s" $namePart) (empty $namePart) }}-readiness
image: {{ include "repositoryGenerator.image.readiness" $subchartDot }}
imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }}
+ securityContext:
+ runAsUser: {{ $subchartDot.Values.user }}
+ runAsGroup: {{ $subchartDot.Values.group }}
command:
- /app/ready.py
args:
diff --git a/kubernetes/common/readinessCheck/values.yaml b/kubernetes/common/readinessCheck/values.yaml
index b15b1c2af3..128c5057cc 100644
--- a/kubernetes/common/readinessCheck/values.yaml
+++ b/kubernetes/common/readinessCheck/values.yaml
@@ -15,6 +15,9 @@
global:
pullPolicy: Always
+user: 100
+group: 65533
+
limits:
cpu: 100m
memory: 100Mi
mber.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
import {Component, Input, OnChanges, Output, SimpleChanges, EventEmitter} from '@angular/core';
import {ElementsTableService} from "./elements-table.service";
import {ModalInformation} from "./element-table-row.model";
import * as _ from 'lodash';
import {Level1Instance} from "../../../models/level1Instance";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../store/reducers";
import {
  deleteGenericModalhelper,
  deleteGenericModalTableDataHelper
} from "../../../storeUtil/utils/global/global.actions";

export class CustomTableColumnDefinition {
  public displayName = '';
  public key : any = '';
  public type? = 'text';
  public filter? = '';
}

@Component({
  selector: 'app-members-table',
  templateUrl: './elements-table.component.html',
  styleUrls: ['./members-table.component.scss']
})

export class ElementsTableComponent implements OnChanges{
  filterValue: string = null;
  allMemberStatusMap = null;
  membersTableService : ElementsTableService;
  headers: CustomTableColumnDefinition[] = [];
  searchQuery = null;

  @Input() modalInformation : ModalInformation;
  @Input() data: Level1Instance[];
  @Output() selectedMembersAmountChange : EventEmitter<number> = new EventEmitter();
  constructor(private _membersTableService : ElementsTableService, private _store : NgRedux<AppState>){
    this.membersTableService = this._membersTableService;
  }

  ngOnChanges(changes: SimpleChanges): void {
    if(_.isNil(this.data)){
      this._membersTableService.resetAll(this.modalInformation.uniqObjectField, this.modalInformation.maxSelectRow);
    }else {
      ElementsTableService.uniqObjectField = this.modalInformation.uniqObjectField;
      this.headers = this.modalInformation.tableHeaders;
      const genericModalHelper = this._store.getState().global.genericModalHelper;
      if(!_.isNil(genericModalHelper) && !_.isNil(genericModalHelper[`${this.modalInformation.type}_TABLE_DATA`]) && !_.isNil(genericModalHelper[`selected${this.modalInformation.type}`])){
        this.updateTablWithDefaultData(this._store.getState().global.genericModalHelper[`${this.modalInformation.type}_TABLE_DATA`]);
      }else {
        this.modalInformation.getElements().subscribe((res)=>{
          this.updateTablWithDefaultData(res);
        });
      }
    }
  }

  updateTablWithDefaultData(tableData) : void{
    this._membersTableService.allElementsStatusMap = this._membersTableService.generateAllMembersStatus(tableData);
    this._membersTableService.filteredMembers = this._membersTableService.sortElementsByName(tableData, "instanceName");
    this._membersTableService.updateAmountsAndCheckAll(this.modalInformation.uniqObjectField, this.modalInformation, this.modalInformation.maxSelectRow);
    this.updateDefaultSelectedRows();
  }
  
  search(searchStr: string): void {
    this.filterValue = searchStr;
    this._membersTableService.filterMembers(this.filterValue, this.modalInformation.type);
  }

  selectItem(item , maxNumberOfRows : number) : void {
    if (maxNumberOfRows === 1) {
      for (let currentItem in this.membersTableService.allElementsStatusMap) {
        if (this.membersTableService.allElementsStatusMap[currentItem].isSelected) {
          this.membersTableService.allElementsStatusMap[currentItem].isSelected = false;
          this.membersTableService.allElementsStatusMap[item[this.membersTableService.staticUniqObjectField]].isSelected = !this.membersTableService.allElementsStatusMap[item[this.membersTableService.staticUniqObjectField]].isSelected;
          return;
        }
      }
      this.membersTableService.allElementsStatusMap[item[this.membersTableService.staticUniqObjectField]].isSelected = !this.membersTableService.allElementsStatusMap[item[this.membersTableService.staticUniqObjectField]].isSelected;
    }
  }

  updateDefaultSelectedRows(): void {
    if(this._store.getState().global.genericModalHelper && this._store.getState().global.genericModalHelper[`selected${this.modalInformation.type}`]){
      const selectedIds = this._store.getState().global.genericModalHelper[`selected${this.modalInformation.type}`];
      for(const id in selectedIds){
        if(!_.isNil(this._membersTableService.allElementsStatusMap[id])){
          this._membersTableService.allElementsStatusMap[id].isSelected = true;
        }
      }
      this._membersTableService.updateAmountsAndCheckAll(this.modalInformation.uniqObjectField, this.modalInformation, this.modalInformation.maxSelectRow);
      this.selectedMembersAmountChange.emit(this._membersTableService.numberOfSelectedRows);
    }
  }

  changeAllCheckboxStatus(status: boolean) : void {
    this._membersTableService.changeAllCheckboxStatus(status);
    this.selectedMembersAmountChange.emit(this._membersTableService.numberOfSelectedRows);
  }


  changeCheckboxStatus(vnfInstanceId: string) : void {
    if (this.modalInformation.maxSelectRow === 1) {
      for (let currentItem in this.membersTableService.allElementsStatusMap) {
        if (this.membersTableService.allElementsStatusMap[currentItem].isSelected) {
          this.membersTableService.allElementsStatusMap[currentItem].isSelected = false;
          this._store.dispatch(deleteGenericModalhelper(`selected${this.modalInformation.type}`, this.membersTableService.allElementsStatusMap[currentItem][this.modalInformation.uniqObjectField]));
          this._store.dispatch(deleteGenericModalTableDataHelper(`${this.modalInformation.type}_TABLE_DATA`));
        }
      }
    }
    this._membersTableService.changeCheckboxStatus(vnfInstanceId, this.data);
    this.selectedMembersAmountChange.emit(this._membersTableService.numberOfSelectedRows);
  }


  getTdInformationItemId(data : {id : string[], value : string[], prefix ?: string}, item) : string {
    let result = item;
    for(const idVal of data.id){
      if(_.isNil(result)) return null;
      result = result[idVal];
    }
    return result;
  }

  getTdInformationItemValue(data : {id : string[], value : string[], prefix ?: string}, item) : string {
    let result = item;
    for(const idVal of data.value){
      if(_.isNil(result)) return null;
      result = result[idVal];
    }
    return !_.isNil(data.prefix) ? data.prefix + result : result;
  }


  getTdListInformationItemValue(data : {id : string[], value : string[], prefix ?: string}, item) : string[] {
    let result = item;

    for(let i = 0 ; i < data.value.length -1 ; i++){
      if(_.isNil(result)) return null;
      result = result[data.value[i]];
    }
    return _.map(result, _.last(data.value));
  }
}