What are best practices for deploying different configurations per environment in Kubernetes/OpenShift?

Kubernetes provides a very elegant mechanism for managing configuration for pods using ConfigMaps. What’s not clear from the documentation is what the recommended practice is for using ConfigMaps to manage different configurations for different environments, and also to deploy configuration changes when they occur.

Assume I’m using a ConfigMap for my pod to set various environment variables or to inject cofiguration files into my container. Evidently some (or all) of those variables or files need to be different depending on which environment the pod is deployed to.

In an ideal world I can make configuration changes and deploy those to the pod without re-building or re-deploying the container image. The implication is that those configuration settings, and the ConfigMap, should probably be stored in a separate source code repository (otherwise a build of the image would be triggered every time configuration changes).

What are some recommended practices for:

  1. maintaining different configuration settings per environment (e.g. separate branch per environment)

  2. automatically deploying configuration changes when they change under source control, but only to the respective environment

When I am deploying Ap-ppart getting error

SP.SOD.executeFunc("SP.js", "ClientContext", initilise_function); 

function initilise_function() {

//_url = _spPageContextInfo.webAbsoluteUrl;  _url = _spPageContextInfo.webServerRelativeUrl; 

}

function CreateListItem_Rest() { var listName = “RESTList2”; var newItemTitle = “New Title Item”; CreateListItemWithDetails(listName, newItemTitle, function () { console.log(“New Item has been created successfully.”); }, function () { console.log(“Ooops, an error occured. Please try again.”); }); }

function CreateListItemWithDetails(listName, newItemTitle, success, failure) {

var dt = new Date(); var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();   var itemType = GetItemTypeForListName(listName); var item = {     "__metadata": { "type": itemType },     "Title": newItemTitle + String(time),     "Test1": String(time),     "Test2": "Rest data insert 2" };  $  .ajax({     url: _url + "/_api/web/lists/getbytitle('" + listName + "')/items",     type: "POST",     contentType: "application/json;odata=verbose",     data: JSON.stringify(item),     headers: {         "accept": "application/json;odata=verbose",         "content-type": "application/json;odata=verbose",         "X-RequestDigest": $  ("#__REQUESTDIGEST").val(),         "IF-MATCH": "*"     },     success: function (data) {         //success(data);         //console.log(data);         alert(data.d);     },     error: function (data) {         //console.log(data);         alert(data.d);     } }); 

}

// Get List Item Type metadata function GetItemTypeForListName(name) { return “SP.Data.” + name.charAt(0).toUpperCase() + name.split(” “).join(“”).slice(1) + “ListItem”; }

Now I have published it to SharePoint online . Added the App part in page.

Please help.

//Error //SCRIPT5007: Unable to get property ‘executeFunc’ of undefined or null reference

//The same JS working perfectly in Default.aspx page . //When I am doing it as web part getting this error .

//SEC7120: [CORS] The origin ‘https://xxxxx.sharepoint.com’ failed to allow a cross-origin document resource at ‘ms-appx-web:///assets/errorpages/forbidframingedge.htm#https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token&client_id=89bee1f7-5e6e-4d8a-9f3d-ecd601259da7&redirect_uri=https%3A%2F%2Fwebshell.suite.office.com%2Fiframe%2FTokenFactoryIframe&state=8d63f13b-4539-4fe4-98f7-60b9f0ed8912&client-request-id=0f9915f5-24ed-4404-a0c4-55ccefabbee4&x-client-SKU=Js&x-client-Ver=1.0.15&nonce=6c61e5c7-9520-4ad5-8c04-4ce9966ea0d0’.

SEC7120: [CORS] The origin ‘https://xxxxxxx.sharepoint.com’ failed to allow a cross-origin document resource at ‘ms-appx-web://microsoft.microsoftedge/assets/errorpages/forbidframingedge.htm#https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token&client_id=89bee1f7-5e6e-4d8a-9f3d-ecd601259da7&redirect_uri=https%3A%2F%2Fwebshell.suite.office.com%2Fiframe%2FTokenFactoryIframe&state=8d63f13b-4539-4fe4-98f7-60b9f0ed8912&client-request-id=0f9915f5-24ed-4404-a0c4-55ccefabbee4&x-client-SKU=Js&x-client-Ver=1.0.15&nonce=6c61e5c7-9520-4ad5-8c04-4ce9966ea0d0’

List created in Visual Studio 2017 not deploying into Sharepoint 2013 properly

I’ve been trying to create both list and library add-ins in VS 2017 for Sharepoint 2013 and when I deploy to my sharepoint dev site, the link to the list or library doesn’t work. I have followed a number of tutorials and they all put the link as such:

<a href="...lists/List1">Library</a>   

(‘Library’ is the name of the library I created)

However, when I follow the same convention, the project won’t recognise the folder.

Anyone have any idea as to why the project won’t recognise this folder?

Manage ContentTypeId & PublishingAssociatedContentType in Page Layout if deploying in different environment

I have created CI/CD for sharepoint Online in Azure DevOps.

I am using PnP provisioning template to deploy changes in Page Layout files from development to QA & Prod environment. Using Apply-PnPProvisioningTemplate.

Example of template file:

  <pnp:Files>     <pnp:File Src="src\_catalog\masterpage\html\TestPageLayout.html" Folder="{masterpagecatalog}" Overwrite="true" ></pnp:File>   </pnp:Files> 

TestPageLayout.html:

This file contains mso:ContentTypeId, mso:PublishingAssociatedContentType etc based on site collection (for example Dev, UAT, Prod). Every site collection have different ContentTypeId & PublishingAssociatedContentType.

If I select a single file (with specific ContentTypeId & PublishingAssociatedContentType) for each sitecollection (Dev, UAT,Prod) & run Apply-PnPProvisioningTemplate, it will break the page layout in other environment because every environment have different ContentTypeId & PublishingAssociatedContentType.

If I have same contenttypeid for used “site content type” (eg. TestContentType) in all environment, so same TestPageLayout.html can work in all environment but ContentTypeId is readOnly & can’t change for “Site Content Type”. Useful link : https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ms460737(v=office.15) & https://social.technet.microsoft.com/wiki/contents/articles/31444.sharepoint-online-content-types-in-powershell-edit.aspx

Other option is change Template file and add property attribute for PageLayout as below: https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/Framework/Provisioning/BaseTemplates/Common/Publishing-Feature-Native-Files.xml

For Dev,Prod & UAT:

Same as above with correct value of ContentTypeId & PublishingAssociatedContentType.

In this approach, I have to manage three different template file based on environmet & manage Release pipeline to call different template file for each environment.

Can anyone please suggest another way to manage ContentTypeId & PublishingAssociatedContentType in Page Layout if deploying in different environment ?

If what you’re deploying to is a public or private domain

So I’m wondering about how you should (best practice) deploy your application to the cloud such as to AWS so that it is secure. Only in the sense of if what you’re deploying to is exposed to the internet or not.

So for example, I’m imagining that you have your main website foo.com, which is exposed to the internet. On Heroku, when you push to Heroku, you are going through their internal network. You aren’t pushing directly to foo.com. You are pushing to an internal network somewhere on Heroku’s platform, and then the newly deployed code is swapped with the old somehow, and how the public internet foo.com is accessing the app. So you never deployed directly to foo.com, so there’s no “back entrances” to the domain. This seems like it helps with security.

What I can imagine though is, in the simple case, just directly deploying to foo.com by ssh-ing into the server and uploading the code.

Instead, what I think would be better is to have a second domain like foo-dev.com, and you ssh into that to deploy your code. This way the foo.com site has no back entrances, and you can only allow your IP to access foo-dev.com or something like that. So deploy is good.

I hope that’s not too confusing. I’m basically just describing 3 ways of deploying, and I’d like to know the answer to the following question related to this. (a) If it is a good idea to have a separate place to deploy the code (as in Heroku, and the last example), or if it’s unnecessary. And if it’s okay to do, the main part of the question is: if you should buy a domain for it, like foo-dev.com, and if it’s common practice to do so. Or if it’s better to just use the IP address directly or something.

I’m imagining something like this:

I have my main app broken into several components (load balancer, database, etc.). Each is on it’s own AWS machine. They are all not touching the internet (private). Then there is the internet facing frontend machine that directs all the traffic to these internal machines. Then on the back side, you have a “deployment” machine, which is what you deploy to. It is only accessible by a handful of people. This way it seems somehow that it prevents the frontend from being deployed directly to, which somehow seems insecure. But I’m not sure if I need a public domain like foo-dev.com to access it, or if that’s common practice, or what.

What should I do with old files when deploying?

I’ve been reading a lot and I just can’t find the answer. When I’m deploying a new angular update to C:\inetpub\wwwroot, what should I do with the old chunk and bundle files?

If I delete them and add the new ones, the app stops working because the browser is caching the old files. Can I do a forced cache refresh here? How?

If I replace all of them, only the main.hashcode.bundle.js has a different hashcode and all the others stay the same and the app still works partially.

Project Name inserted in URL after deploying to hosting server

I created a Java Web application using Spring MVC, Spring Security and MySQL. This app works fine on my development machine. But when I :

  1. Open hostingURL.com –> The login page is displayed

  2. Enter incorrect ID and password –> The URL created by Tomcat is myhostingsite.com/MyExampleProject/loginerror whereas it should be myhostingsite.com/loginerror

  3. Enter correct ID and password –> The URL redirected is myhostingsite.com/MyExampleProject/home whereas it should be myhostingsite.com/home

And myhostingsite.com is mapped to [some-IP-here]/MyProjectName on the ZPanel of my web site.

Due to this insertion of MyProjectName after site name the URL is not being found by the web server and 404 is displayed on browser.
Anybody please tell why this project name is being inserted after hosting working fine on my NetBeans. The Spring Security has following:

<security:form-login login-page="/login"          default-target-url="/home"          authentication-failure-url="/loginerror"         username-parameter="username"         password-parameter="password" />      <security:access-denied-handler error-page="/403" />      <security:logout logout-success-url="/logout_cleanup"   logout-url="/logout"/> 

And the login page is:

<form action="login" method="post">             <div class="form-group">               <div class="form-label-group">                 <input type="text" id="username" name="username" class="form-control" placeholder="User Name" required="required" autofocus="autofocus">                 <label for="username">User Name</label>               </div>             </div>             <div class="form-group">               <div class="form-label-group">                 <input type="password" id="password" name="password" class="form-control" placeholder="Password" required="required">                 <label for="password">Password</label>               </div>             </div>             <div class="form-group">               <font color="$  {color}">$  {message}</font><br/>             </div>             <input type="submit" class="btn btn-primary btn-block" Value="Login"/> </form>

DigitalOcean: deploying war file fine, but no dependencies are downloaded

I have a VPS on DigitalOcean I try to deploy an app to. I have Tomcat and Maven installed there and I have copied the local .war file to /tomcat/webapps. After restart the .war gets unpackaged fine.

However, when I try to make use of some servlets I get javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/json/JSONObject error, meaning that even though I have a pom.xml file with needed dependency:

 <!-- https://mvnrepository.com/artifact/org.json/json -->     <dependency>         <groupId>org.json</groupId>         <artifactId>json</artifactId>         <version>20180813</version>     </dependency> 

It wasn’t used during the deploy.

How should I proceed? Is there a way to download all dependencies using PuTTy?